diff --git a/phpdotnet/phd/Package/Generic/XHTML.php b/phpdotnet/phd/Package/Generic/XHTML.php index 842a68af..e06981ae 100644 --- a/phpdotnet/phd/Package/Generic/XHTML.php +++ b/phpdotnet/phd/Package/Generic/XHTML.php @@ -67,7 +67,8 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML { /* DEFAULT */ 'span', 'ooclass' => array( /* DEFAULT */ 'strong', - 'classsynopsisinfo' => 'format_classsynopsisinfo_ooclass_classname', + 'classsynopsisinfo' => 'format_classsynopsisinfo_ooclass_classname', + 'interfacesynopsisinfo' => 'format_interfacesynopsisinfo_ooclass_classname', ), ), 'classsynopsis' => 'format_classsynopsis', @@ -134,6 +135,8 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML { 'indexdiv' => 'format_dl', 'indexentry' => 'dd', 'initializer' => 'format_initializer', + 'interfacesynopsis' => 'format_interfacesynopsis', + 'interfacesynopsisinfo' => 'format_interfacesynopsisinfo', 'itemizedlist' => 'format_itemizedlist', 'legalnotice' => 'format_chunk', 'listitem' => array( @@ -162,12 +165,14 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML { 'oointerface' => array( /* DEFAULT */ 'span', 'classsynopsisinfo' => 'format_classsynopsisinfo_oointerface', + 'interfacesynopsisinfo' => 'format_interfacesynopsisinfo_oointerface', ), 'interfacename' => array( /* DEFAULT */ 'span', 'oointerface' => array( - /* DEFAULT */ 'span', - 'classsynopsisinfo' => 'format_classsynopsisinfo_oointerface_interfacename', + /* DEFAULT */ 'format_suppressed_tags', + 'classsynopsisinfo' => 'format_classsynopsisinfo_oointerface_interfacename', + 'interfacesynopsisinfo' => 'format_suppressed_tags', ), ), 'exceptionname' => 'span', @@ -381,7 +386,8 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML { /* DEFAULT */ false, 'ooclass' => array( /* DEFAULT */ false, - 'classsynopsis' => 'format_classsynopsis_ooclass_classname_text', + 'classsynopsis' => 'format_classsynopsis_ooclass_classname_text', + 'interfacesynopsis' => 'format_interfacesynopsis_ooclass_classname_text', ), ), 'methodname' => array( @@ -393,6 +399,7 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML { 'methodsynopsis' => array( /* DEFAULT */ false, 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', + 'interfacesynopsis' => 'format_interfacesynopsis_methodsynopsis_methodname_text', ), 'destructorsynopsis' => array( /* DEFAULT */ false, @@ -432,6 +439,14 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML { "fieldsynopsis" => array( "modifier" => "public", ), + "interfacesynopsis" => array( + "close" => false, + "classname" => false, + ), + "interfacesynopsisinfo" => array( + "extends" => false, + "oointerface" => false, + ), "methodsynopsis" => array( "returntypes" => [], "type_separator" => null, @@ -974,6 +989,94 @@ public function format_classsynopsis($open, $name, $attrs) { return ""; } + public function format_interfacesynopsisinfo_ooclass_classname($open, $name, $attrs) + { + if ($open) { + if ($this->cchunk["interfacesynopsisinfo"]["oointerface"] === false) { + $this->cchunk["interfacesynopsisinfo"]["oointerface"] = true; + return 'interface '; + } + + return ""; + } + + if ($this->cchunk["interfacesynopsisinfo"]["oointerface"] === true) { + $this->cchunk["interfacesynopsisinfo"]["oointerface"] = null; + } + + return ""; + } + + public function format_interfacesynopsisinfo_oointerface($open, $name, $attrs) { + if ($open) { + if ($this->cchunk["interfacesynopsisinfo"]["extends"] === false) { + $this->cchunk["interfacesynopsisinfo"]["extends"] = true; + return ''; + } + + return ', '; + } + + return ""; + } + + public function format_interfacesynopsisinfo($open, $name, $attrs) + { + $this->cchunk["interfacesynopsisinfo"] = $this->dchunk["interfacesynopsisinfo"]; + if ($open) { + $name .= ' classsynopsisinfo'; + + if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"]) && $attrs[Reader::XMLNS_DOCBOOK]["role"] == "comment") { + return '
/* '; + } + + return '
'; + } + + if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"]) && $attrs[Reader::XMLNS_DOCBOOK]["role"] == "comment") { + return ' */
'; + } + $this->cchunk["interfacesynopsis"]["close"] = true; + + return ' {
'; + } + + public function format_interfacesynopsis_methodsynopsis_methodname_text($value, $tag) { + $value = $this->TEXT($value); + if ($this->cchunk["interfacesynopsis"]["classname"] === false) { + return $value; + } + if (strpos($value, '::')) { + $explode = '::'; + } elseif (strpos($value, '->')) { + $explode = '->'; + } elseif (strpos($value, '->')) { + $explode = '->'; + } else { + return $value; + } + + list($class, $method) = explode($explode, $value); + if ($class !== $this->cchunk["interfacesynopsis"]["classname"]) { + return $value; + } + return $method; + } + + public function format_interfacesynopsis($open, $name, $attrs) { + if ($open) { + $name .= ' classsynopsis'; + return '
'; + } + + if ($this->cchunk["interfacesynopsis"]["close"] === true) { + $this->cchunk["interfacesynopsis"]["close"] = false; + return "}
"; + } + + return ""; + } + public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) { $value = $this->TEXT($value); if ($this->cchunk["classsynopsis"]["classname"] === false) { @@ -1001,6 +1104,11 @@ public function format_classsynopsis_ooclass_classname_text($value, $tag) { return $this->TEXT($value); } + public function format_interfacesynopsis_ooclass_classname_text($value, $tag) { + $this->cchunk["interfacesynopsis"]["classname"] = $value; + return $this->TEXT($value); + } + public function format_fieldsynopsis($open, $name, $attrs) { $this->cchunk["fieldsynopsis"] = $this->dchunk["fieldsynopsis"]; if ($open) { @@ -1063,6 +1171,7 @@ public function format_initializer($open, $name, $attrs) { } return '
'; } + public function format_parameter($open, $name, $attrs, $props) { if ($props["empty"]) { diff --git a/phpdotnet/phd/Package/PHP/XHTML.php b/phpdotnet/phd/Package/PHP/XHTML.php index 2062436c..e46d0a11 100644 --- a/phpdotnet/phd/Package/PHP/XHTML.php +++ b/phpdotnet/phd/Package/PHP/XHTML.php @@ -11,7 +11,8 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML { /* DEFAULT */ 'span', 'ooclass' => array( /* DEFAULT */ 'format_suppressed_tags', - 'classsynopsisinfo' => 'format_classsynopsisinfo_ooclass_classname', + 'classsynopsisinfo' => 'format_classsynopsisinfo_ooclass_classname', + 'interfacesynopsisinfo' => 'format_interfacesynopsisinfo_ooclass_classname', ), ), 'chapter' => 'format_container_chunk', @@ -96,7 +97,8 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML { /* DEFAULT */ 'format_classname_text', 'ooclass' => array( /* DEFAULT */ 'format_classname_text', - 'classsynopsis' => 'format_classsynopsis_ooclass_classname_text', + 'classsynopsis' => 'format_classsynopsis_ooclass_classname_text', + 'interfacesynopsis' => 'format_interfacesynopsis_ooclass_classname_text', ), ), 'methodname' => array( @@ -106,6 +108,7 @@ abstract class Package_PHP_XHTML extends Package_Generic_XHTML { ), 'methodsynopsis' => array( /* DEFAULT */ 'format_classsynopsis_methodsynopsis_methodname_text', + 'interfacesynopsis' => 'format_interfacesynopsis_methodsynopsis_methodname_text', ), 'destructorsynopsis' => array( /* DEFAULT */ 'format_classsynopsis_methodsynopsis_methodname_text', @@ -710,6 +713,22 @@ public function format_classsynopsis_ooclass_classname_text($value, $tag) { parent::format_classsynopsis_ooclass_classname_text($value, $tag); } + public function format_interfacesynopsis_methodsynopsis_methodname_text($value, $tag) { + if ($this->cchunk["interfacesynopsis"]["classname"]) { + if (strpos($value, "::") === false && strpos($value, "->") === false) { + $value = $this->cchunk["interfacesynopsis"]["classname"] . "::" . $value; + } + } + + $display_value = parent::format_interfacesynopsis_methodsynopsis_methodname_text($value, $tag); + return $this->format_function_text($value, $tag, $display_value); + } + + public function format_interfacesynopsis_ooclass_classname_text($value, $tag) { + /* intentionally not return the value */ + parent::format_interfacesynopsis_ooclass_classname_text($value, $tag); + } + public function format_classname_text($value, $tag) { if (($filename = $this->getClassnameLink(strtolower($value))) !== null && $this->cchunk["phpdoc:classref"] !== strtolower($value)) { $href = $this->chunked ? $filename.$this->ext : "#$filename"; diff --git a/phpdotnet/phd/Render.php b/phpdotnet/phd/Render.php index 4117b4f4..5885579b 100644 --- a/phpdotnet/phd/Render.php +++ b/phpdotnet/phd/Render.php @@ -189,6 +189,7 @@ public function execute(Reader $r) { /* {{{ */ /* The following if is to skip unnecessary whitespaces in the implements list */ if ( + ($this->STACK[$r->depth - 1] === 'interfacesynopsisinfo' && $this->STACK[$r->depth] === 'oointerface') || ($this->STACK[$r->depth - 1] === 'classsynopsisinfo' && $this->STACK[$r->depth] === 'oointerface') || ($this->STACK[$r->depth - 1] === 'oointerface' && $this->STACK[$r->depth] === 'interfacename') ) {