diff --git a/phpdotnet/phd/Package/Generic/XHTML.php b/phpdotnet/phd/Package/Generic/XHTML.php index 52433334..0b5fb7fd 100644 --- a/phpdotnet/phd/Package/Generic/XHTML.php +++ b/phpdotnet/phd/Package/Generic/XHTML.php @@ -150,6 +150,12 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML { 'note' => 'format_note', 'orgname' => 'span', 'othercredit' => 'format_div', + /** Package/Namespace synopsis related tags */ + 'packagesynopsis' => 'format_packagesynopsis', + 'package' => [ + /* DEFAULT */ 'span', + 'packagesynopsis' => 'format_packagesynopsis_package', + ], /** Class Synopsis related tags */ 'classsynopsis' => 'format_classsynopsis', 'classsynopsisinfo' => 'format_classsynopsisinfo', @@ -532,6 +538,7 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML { protected $cchunk = array(); /* Default Chunk variables */ private $dchunk = array( + "packagesynopsis" => false, "classsynopsis" => [ "close" => false, "classname" => false, @@ -1250,6 +1257,8 @@ public function format_classsynopsis($open, $name, $attrs, $props) { /** Legacy presentation does not use the class attribute */ $this->cchunk["classsynopsis"]['legacy'] = !isset($attrs[Reader::XMLNS_DOCBOOK]["class"]); + $inPackageSynopsis = $this->cchunk["packagesynopsis"] ?? false; + if ($this->cchunk["classsynopsis"]['legacy']) { if ($open) { // Think this just needs to be set on open and it will persist @@ -1261,6 +1270,9 @@ public function format_classsynopsis($open, $name, $attrs, $props) { $this->cchunk["classsynopsis"]["interface"] = true; } + if ($inPackageSynopsis) { + return ''; + } return '
'; } @@ -1271,6 +1283,9 @@ public function format_classsynopsis($open, $name, $attrs, $props) { } return "
"; */ + if ($inPackageSynopsis) { + return '}'; + } return "}"; } @@ -1281,8 +1296,14 @@ public function format_classsynopsis($open, $name, $attrs, $props) { + substr_count($props['innerXml'], '') + substr_count($props['innerXml'], ''); $this->cchunk["classsynopsis"]['nb_list'] = $occurrences; + if ($inPackageSynopsis) { + return '
'; + } return '
'; } else { + if ($inPackageSynopsis) { + return '}'; + } return '}
'; } } @@ -1309,11 +1330,33 @@ public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag return $method; } + public function format_packagesynopsis($open, $name, $attrs, $props) { + if ($open) { + $this->cchunk["packagesynopsis"] = true; + return '
'; + } + $this->cchunk["packagesynopsis"] = false; + return '
'; + } + + public function format_packagesynopsis_package($open, $name, $attrs, $props) { + if ($open) { + return 'namespace '; + } + return ';
'; + } + public function format_enumsynopsis($open, $name, $attrs, $props) { + $inPackageSynopsis = $this->cchunk["packagesynopsis"] ?? false; if ($open) { - //return '
'; + if ($inPackageSynopsis) { + return '
'; + } return '
'; } else { + if ($inPackageSynopsis) { + return '}'; + } return '}
'; } } diff --git a/tests/package/php/data/packagesynopsis_rendering.xml b/tests/package/php/data/packagesynopsis_rendering.xml new file mode 100644 index 00000000..1cd3013a --- /dev/null +++ b/tests/package/php/data/packagesynopsis_rendering.xml @@ -0,0 +1,41 @@ + + + +
+ 1. Namespaced class with packagesynopsis + + BcMath + + + final + readonly + Number + + + implements + Stringable + + + +
+ +
+ 2. Namespaced enum with packagesynopsis + + Pcntl + + QosClass + + Background + Background QoS + + + +
+ +
+ 3. Standalone package element + The Dom namespace. +
+ +
diff --git a/tests/package/php/packagesynopsis_rendering_001.phpt b/tests/package/php/packagesynopsis_rendering_001.phpt new file mode 100644 index 00000000..ba011850 --- /dev/null +++ b/tests/package/php/packagesynopsis_rendering_001.phpt @@ -0,0 +1,60 @@ +--TEST-- +Package synopsis rendering (GH-194 packagesynopsis and package elements) +--FILE-- +xmlFile = $xmlFile; + +$format = new TestPHPChunkedXHTML($config, $outputHandler); + +$render = new TestRender(new Reader($outputHandler), $config, $format); + +$render->run(); +?> +--EXPECT-- +Filename: packagesynopsis_rendering.html +Content: +
+ +
+

1. Namespaced class with packagesynopsis

+
+ namespace BcMath;
+
+ + final + readonly + class Number + + + implements + Stringable {
+ } +
+
+ +
+

2. Namespaced enum with packagesynopsis

+
+ namespace Pcntl;
+
+ enum QosClass
{
+
+ case Background + ; //Background QoS

+
+ } +
+
+ +
+

3. Standalone package element

+

The Dom namespace.

+
+ +