diff --git a/phpdotnet/phd/Index.php b/phpdotnet/phd/Index.php
index 77e0b0fe..2f0d5d3e 100644
--- a/phpdotnet/phd/Index.php
+++ b/phpdotnet/phd/Index.php
@@ -35,7 +35,7 @@ class Index extends Format
'phpdoc:varentry' => 'format_chunk',
'preface' => 'format_chunk',
'refentry' => 'format_refentry',
- 'reference' => 'format_container_chunk',
+ 'reference' => 'format_reference',
'sect1' => 'format_chunk',
'section' => array(
/* DEFAULT */ false,
@@ -446,4 +446,14 @@ public function setMembership($membership) {
$this->currentMembership = $membership;
}
+ public function format_reference($open, $name, $attrs, $props) {
+ if (isset($attrs[Reader::XMLNS_DOCBOOK]['role'])) {
+ $name = match ($attrs[Reader::XMLNS_DOCBOOK]['role']) {
+ "class" => "phpdoc:classref",
+ "exception" => "phpdoc:exceptionref",
+ default => $name,
+ };
+ }
+ return $this->format_container_chunk($open, $name, $attrs, $props);
+ }
}
diff --git a/phpdotnet/phd/Package/Generic/XHTML.php b/phpdotnet/phd/Package/Generic/XHTML.php
index 56aa6481..6a7dc8e6 100644
--- a/phpdotnet/phd/Package/Generic/XHTML.php
+++ b/phpdotnet/phd/Package/Generic/XHTML.php
@@ -1626,8 +1626,22 @@ public function format_programlisting_text($value, $tag) {
}
public function format_screen($open, $name, $attrs) {
if ($open) {
+ if ($this->getRole() !== "examples"
+ && $this->getRole() !== "description"
+ && $this->getRole() !== "notes"
+ && $this->getRole() !== "returnvalues"
+ && $this->getRole() !== "parameters") {
+ $this->pushRole('');
+ }
return '
';
}
+ if ($this->getRole() !== "examples"
+ && $this->getRole() !== "description"
+ && $this->getRole() !== "notes"
+ && $this->getRole() !== "returnvalues"
+ && $this->getRole() !== "parameters") {
+ $this->popRole();
+ }
return '
';
}
public function format_constant($open, $name, $attrs)
diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php
index 912ef562..fe6d673a 100644
--- a/phpdotnet/phd/Package/PHP/XHTML.php
+++ b/phpdotnet/phd/Package/PHP/XHTML.php
@@ -25,7 +25,7 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML {
'phpdoc:exceptionref' => 'format_class_chunk',
'phpdoc:varentry' => 'format_varentry_chunk',
'refentry' => 'format_refentry',
- 'reference' => 'format_container_chunk',
+ 'reference' => 'format_reference',
'refpurpose' => 'format_refpurpose',
'refsynopsisdiv' => 'format_refsynopsisdiv',
'set' => 'format_root_chunk',
@@ -152,6 +152,7 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML {
/* DEFAULT */ 'format_suppressed_text',
'phpdoc:classref' => 'format_grep_classname_text',
'phpdoc:exceptionref' => 'format_grep_classname_text',
+ 'reference' => 'format_reference_titleabbrev_text',
'refentry' => 'format_grep_classname_text',
),
'varname' => array(
@@ -1061,6 +1062,26 @@ public function format_class_chunk($open, $name, $attrs, $props) {
return $this->format_container_chunk($open, "reference", $attrs, $props);
}
-}
-
+ public function format_reference($open, $name, $attrs, $props) {
+ if (isset($attrs[Reader::XMLNS_DOCBOOK]['role'])) {
+ if ($attrs[Reader::XMLNS_DOCBOOK]['role'] === "class"
+ || $attrs[Reader::XMLNS_DOCBOOK]['role'] === "exception") {
+ if ($open) {
+ $this->pushRole($attrs[Reader::XMLNS_DOCBOOK]['role']);
+ } else {
+ $this->popRole();
+ }
+ return $this->format_class_chunk($open, $name, $attrs, $props);
+ }
+ }
+ return $this->format_container_chunk($open, $name, $attrs, $props);
+ }
+ public function format_reference_titleabbrev_text($value, $tag) {
+ if ($this->getRole() === "class"
+ || $this->getRole() === "exception") {
+ return $this->format_grep_classname_text($value, $tag);
+ }
+ return $this->format_suppressed_text($value, $tag);
+ }
+}
diff --git a/tests/package/php/class_rendering_001.phpt b/tests/package/php/class_rendering_001.phpt
new file mode 100644
index 00000000..ee4a4736
--- /dev/null
+++ b/tests/package/php/class_rendering_001.phpt
@@ -0,0 +1,129 @@
+--TEST--
+Class rendering 001 - phpdoc:classref rendering
+--FILE--
+ $xml_file]);
+
+$format = new TestPHPChunkedXHTML;
+$render = new TestRender(new Reader, new Config, $format);
+
+$render->run();
+?>
+--EXPECTF--
+Filename: classname.construct.html
+Content:
+
+
+
ClassName::__construct
+
(No version information available, might only be in Git)
ClassName::__construct — Returns new ClassName object
+
+
+
+
+ Description
+
public ClassName::__construct(
string $firstParameter
= "now")
+
+
+
+
+
+
+
Parameters
+
+
+ firstParameter
+ -
+
+ The description of the parameter.
+
+
+
+
+
+
+
+
+
Return Values
+
+ Return values of the method.
+
+
+
+
+
+
Errors/Exceptions
+
+ Exceptions thrown and/or errors raised by the method.
+
+
+
+
+
+Filename: class.classname.html
+Content:
+
+
+
The ClassName class
+
+
+
(No version information available, might only be in Git)
+
+
+
Introduction
+
+ Introductory paragraph about the class.
+
+
+
+
+
Class synopsis
+
+
+
+ class ClassName
+
+
+
+ implements
+ InterfaceName {
+
+
+
+
+
+
+
+
+ }
+
+
+
+
+
Predefined Constants
+
+
+ ClassName::FIRST_CONSTANT
+ -
+
+ The description of the class constant.
+
+
+
+
+
+
+
+
+
diff --git a/tests/package/php/class_rendering_002.phpt b/tests/package/php/class_rendering_002.phpt
new file mode 100644
index 00000000..50e84ff4
--- /dev/null
+++ b/tests/package/php/class_rendering_002.phpt
@@ -0,0 +1,129 @@
+--TEST--
+Class rendering 002 - reference element with role="class" rendering
+--FILE--
+ $xml_file]);
+
+$format = new TestPHPChunkedXHTML;
+$render = new TestRender(new Reader, new Config, $format);
+
+$render->run();
+?>
+--EXPECTF--
+Filename: classname.construct.html
+Content:
+
+
+
ClassName::__construct
+
(No version information available, might only be in Git)
ClassName::__construct — Returns new ClassName object
+
+
+
+
+ Description
+
public ClassName::__construct(
string $firstParameter
= "now")
+
+
+
+
+
+
+
Parameters
+
+
+ firstParameter
+ -
+
+ The description of the parameter.
+
+
+
+
+
+
+
+
+
Return Values
+
+ Return values of the method.
+
+
+
+
+
+
Errors/Exceptions
+
+ Exceptions thrown and/or errors raised by the method.
+
+
+
+
+
+Filename: class.classname.html
+Content:
+
+
+
The ClassName class
+
+
+
(No version information available, might only be in Git)
+
+
+
Introduction
+
+ Introductory paragraph about the class.
+
+
+
+
+
Class synopsis
+
+
+
+ class ClassName
+
+
+
+ implements
+ InterfaceName {
+
+
+
+
+
+
+
+
+ }
+
+
+
+
+
Predefined Constants
+
+
+ ClassName::FIRST_CONSTANT
+ -
+
+ The description of the class constant.
+
+
+
+
+
+
+
+
+
diff --git a/tests/package/php/class_rendering_003.phpt b/tests/package/php/class_rendering_003.phpt
new file mode 100644
index 00000000..d378c1f3
--- /dev/null
+++ b/tests/package/php/class_rendering_003.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Class rendering 003 - compare output of phpdoc:classref and reference element with role="class" rendering
+--FILE--
+ $xml_filePhpdoc]);
+
+$formatPhpdoc = new TestPHPChunkedXHTML;
+$renderPhpdoc = new TestRender(new Reader, new Config, $formatPhpdoc);
+
+ob_start();
+$renderPhpdoc->run();
+$phpdocOutput = ob_get_clean();
+
+
+$xml_fileReferenceWithRole = __DIR__ . "/data/class_rendering_002.xml";
+
+Config::init(["xml_file" => $xml_fileReferenceWithRole]);
+
+$formatReferenceWithRole = new TestPHPChunkedXHTML;
+$renderReferenceWithRole = new TestRender(new Reader, new Config, $formatReferenceWithRole);
+
+ob_start();
+$renderReferenceWithRole->run();
+$referenceWithRoleOutput = ob_get_clean();
+
+var_dump($phpdocOutput === $referenceWithRoleOutput);
+?>
+--EXPECT--
+bool(true)
diff --git a/tests/package/php/data/class_rendering_001.xml b/tests/package/php/data/class_rendering_001.xml
new file mode 100644
index 00000000..4a46b5d0
--- /dev/null
+++ b/tests/package/php/data/class_rendering_001.xml
@@ -0,0 +1,106 @@
+
+
+
+ The ClassName class
+ ClassName
+
+
+
+
+ Introduction
+
+ Introductory paragraph about the class.
+
+
+
+
+ Class synopsis
+
+
+
+ ClassName
+
+
+
+ implements
+ InterfaceName
+
+
+ Constants
+
+ public
+ const
+ string
+ ClassName::FIRST_CONSTANT
+ "Initial value"
+
+
+ Methods
+
+
+
+ ClassName::__construct
+ Returns new ClassName object
+
+
+
+ Description
+
+ public ClassName::__construct
+ stringfirstParameter"now"
+
+
+ Returns new a ClassName object.
+
+
+
+
+ Parameters
+
+
+ firstParameter
+
+
+ The description of the parameter.
+
+
+
+
+
+
+
+ Return Values
+
+ Return values of the method.
+
+
+
+
+ Errors/Exceptions
+
+ Exceptions thrown and/or errors raised by the method.
+
+
+
+
+
+
+
+
+
+ Predefined Constants
+
+
+ ClassName::FIRST_CONSTANT
+
+
+ The description of the class constant.
+
+
+
+
+
+
+
+
+
diff --git a/tests/package/php/data/class_rendering_002.xml b/tests/package/php/data/class_rendering_002.xml
new file mode 100644
index 00000000..34a466d6
--- /dev/null
+++ b/tests/package/php/data/class_rendering_002.xml
@@ -0,0 +1,106 @@
+
+
+
+ The ClassName class
+ ClassName
+
+
+
+
+ Introduction
+
+ Introductory paragraph about the class.
+
+
+
+
+ Class synopsis
+
+
+
+ ClassName
+
+
+
+ implements
+ InterfaceName
+
+
+ Constants
+
+ public
+ const
+ string
+ ClassName::FIRST_CONSTANT
+ "Initial value"
+
+
+ Methods
+
+
+
+ ClassName::__construct
+ Returns new ClassName object
+
+
+
+ Description
+
+ public ClassName::__construct
+ stringfirstParameter"now"
+
+
+ Returns new a ClassName object.
+
+
+
+
+ Parameters
+
+
+ firstParameter
+
+
+ The description of the parameter.
+
+
+
+
+
+
+
+ Return Values
+
+ Return values of the method.
+
+
+
+
+ Errors/Exceptions
+
+ Exceptions thrown and/or errors raised by the method.
+
+
+
+
+
+
+
+
+
+ Predefined Constants
+
+
+ ClassName::FIRST_CONSTANT
+
+
+ The description of the class constant.
+
+
+
+
+
+
+
+
+
diff --git a/tests/package/php/data/exception_rendering_001.xml b/tests/package/php/data/exception_rendering_001.xml
new file mode 100644
index 00000000..855b0052
--- /dev/null
+++ b/tests/package/php/data/exception_rendering_001.xml
@@ -0,0 +1,88 @@
+
+
+ The ExceptionName Exception
+ ExceptionName
+
+
+
+
+ Introduction
+
+ An ExceptionName exception.
+
+
+
+
+ Class synopsis
+
+
+
+ ExceptionName
+
+
+
+ extends
+ Exception
+
+
+ Properties
+
+ protected
+ int
+ propertyName
+ "Initial name"
+
+
+ Methods
+
+
+ ExceptionName::__construct
+ Constructs the exception
+
+
+
+ Description
+
+ public ExceptionName::__construct
+ stringpropertyName""
+
+
+ Constructs the Exception.
+
+
+
+
+ Parameters
+
+
+
+ parameterName
+
+
+ Description of the parameter
+
+
+
+
+
+
+
+
+
+
+
+
+ Properties
+
+
+ propertyName
+
+ Description of the property
+
+
+
+
+
+
+
+
diff --git a/tests/package/php/data/exception_rendering_002.xml b/tests/package/php/data/exception_rendering_002.xml
new file mode 100644
index 00000000..17248fa6
--- /dev/null
+++ b/tests/package/php/data/exception_rendering_002.xml
@@ -0,0 +1,88 @@
+
+
+ The ExceptionName Exception
+ ExceptionName
+
+
+
+
+ Introduction
+
+ An ExceptionName exception.
+
+
+
+
+ Class synopsis
+
+
+
+ ExceptionName
+
+
+
+ extends
+ Exception
+
+
+ Properties
+
+ protected
+ int
+ propertyName
+ "Initial name"
+
+
+ Methods
+
+
+ ExceptionName::__construct
+ Constructs the exception
+
+
+
+ Description
+
+ public ExceptionName::__construct
+ stringpropertyName""
+
+
+ Constructs the Exception.
+
+
+
+
+ Parameters
+
+
+
+ parameterName
+
+
+ Description of the parameter
+
+
+
+
+
+
+
+
+
+
+
+
+ Properties
+
+
+ propertyName
+
+ Description of the property
+
+
+
+
+
+
+
+
diff --git a/tests/package/php/exception_rendering_001.phpt b/tests/package/php/exception_rendering_001.phpt
new file mode 100644
index 00000000..c1778faa
--- /dev/null
+++ b/tests/package/php/exception_rendering_001.phpt
@@ -0,0 +1,110 @@
+--TEST--
+Exception rendering 001 - phpdoc:exceptionref rendering
+--FILE--
+ $xml_file]);
+
+$format = new TestPHPChunkedXHTML;
+$render = new TestRender(new Reader, new Config, $format);
+
+$render->run();
+?>
+--EXPECTF--
+Filename: exceptionname.construct.html
+Content:
+
+
+
ExceptionName::__construct
+
(No version information available, might only be in Git)
ExceptionName::__construct — Constructs the exception
+
+
+
+
+ Description
+
public ExceptionName::__construct(
string $propertyName
= "")
+
+
+
+
+
+
+ Parameters
+
+
+
+ parameterName
+ -
+
+ Description of the parameter
+
+
+
+
+
+
+
+
+Filename: class.exceptionname.html
+Content:
+
+
The ExceptionName Exception
+
+
+
(No version information available, might only be in Git)
+
+
+ Introduction
+
+ An ExceptionName exception.
+
+
+
+
+ Class synopsis
+
+
+
+ class ExceptionName
+
+
+
+ extends
+ Exception
+ {
+
+
+
+
+
+
+
+ }
+
+
+
+
+ Properties
+
+
+ - propertyName
+ -
+
Description of the property
+
+
+
+
+
+
+
+
diff --git a/tests/package/php/exception_rendering_002.phpt b/tests/package/php/exception_rendering_002.phpt
new file mode 100644
index 00000000..cc90b8cd
--- /dev/null
+++ b/tests/package/php/exception_rendering_002.phpt
@@ -0,0 +1,110 @@
+--TEST--
+Exception rendering 002 - reference element with role="exception" rendering
+--FILE--
+ $xml_file]);
+
+$format = new TestPHPChunkedXHTML;
+$render = new TestRender(new Reader, new Config, $format);
+
+$render->run();
+?>
+--EXPECTF--
+Filename: exceptionname.construct.html
+Content:
+
+
+
ExceptionName::__construct
+
(No version information available, might only be in Git)
ExceptionName::__construct — Constructs the exception
+
+
+
+
+ Description
+
public ExceptionName::__construct(
string $propertyName
= "")
+
+
+
+
+
+
+ Parameters
+
+
+
+ parameterName
+ -
+
+ Description of the parameter
+
+
+
+
+
+
+
+
+Filename: class.exceptionname.html
+Content:
+
+
The ExceptionName Exception
+
+
+
(No version information available, might only be in Git)
+
+
+ Introduction
+
+ An ExceptionName exception.
+
+
+
+
+ Class synopsis
+
+
+
+ class ExceptionName
+
+
+
+ extends
+ Exception
+ {
+
+
+
+
+
+
+
+ }
+
+
+
+
+ Properties
+
+
+ - propertyName
+ -
+
Description of the property
+
+
+
+
+
+
+
+
diff --git a/tests/package/php/exception_rendering_003.phpt b/tests/package/php/exception_rendering_003.phpt
new file mode 100644
index 00000000..e7a61ca0
--- /dev/null
+++ b/tests/package/php/exception_rendering_003.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Exception rendering 003 - compare output of phpdoc:exceptionref and reference element with role="exception" rendering
+--FILE--
+ $xml_filePhpdoc]);
+
+$formatPhpdoc = new TestPHPChunkedXHTML;
+$renderPhpdoc = new TestRender(new Reader, new Config, $formatPhpdoc);
+
+ob_start();
+$renderPhpdoc->run();
+$phpdocOutput = ob_get_clean();
+
+
+$xml_fileReferenceWithRole = __DIR__ . "/data/exception_rendering_002.xml";
+
+Config::init(["xml_file" => $xml_fileReferenceWithRole]);
+
+$formatReferenceWithRole = new TestPHPChunkedXHTML;
+$renderReferenceWithRole = new TestRender(new Reader, new Config, $formatReferenceWithRole);
+
+ob_start();
+$renderReferenceWithRole->run();
+$referenceWithRoleOutput = ob_get_clean();
+
+var_dump($phpdocOutput === $referenceWithRoleOutput);
+?>
+--EXPECT--
+bool(true)