Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions phpdotnet/phd/Package/Generic/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -974,14 +974,28 @@ public function format_fieldsynopsis_modifier_text($value, $tag) {
return $this->TEXT($value);
}

public function format_methodsynopsis($open, $name, $attrs) {
public function format_methodsynopsis($open, $name, $attrs, $props) {
if ($open) {
$this->params = array("count" => 0, "opt" => false, "init" => false, "content" => "", "ellipsis" => '');

$this->params = array(
"count" => 0,
"opt" => false,
"init" => false,
"content" => "",
"ellipsis" => '',
"paramCount" => substr_count($props["innerXml"], "<methodparam")
);

$id = (isset($attrs[Reader::XMLNS_XML]["id"]) ? ' id="'.$attrs[Reader::XMLNS_XML]["id"].'"' : '');
return '<div class="'.$name.' dc-description"'.$id.'>';
}

$content = "";
$content .= " )";
if ($this->params["paramCount"] > 3) {
$content .= "<br>";
}

$content .= ")";

$content .= "</div>\n";

Expand Down Expand Up @@ -1025,7 +1039,7 @@ public function format_parameter($open, $name, $attrs, $props)

public function format_void($open, $name, $attrs, $props) {
if ($props['sibling'] == 'methodname') {
return ' (';
return '(';
} else {
return '<span class="type"><span class="type void">void</span></span>';
}
Expand All @@ -1034,8 +1048,11 @@ public function format_void($open, $name, $attrs, $props) {
public function format_methodparam($open, $name, $attrs) {
if ($open) {
$content = '';
if ($this->params["count"] == 0) {
$content .= " (";
if ($this->params["count"] === 0) {
$content .= "(";
if ($this->params["paramCount"] > 3) {
$content .= "<br>&nbsp;&nbsp;&nbsp;&nbsp;";
}
}
if (isset($attrs[Reader::XMLNS_DOCBOOK]["choice"]) && $attrs[Reader::XMLNS_DOCBOOK]["choice"] == "opt") {
$this->params["opt"] = true;
Expand All @@ -1044,8 +1061,13 @@ public function format_methodparam($open, $name, $attrs) {
}
if ($this->params["count"]) {
$content .= ",";
if ($this->params["paramCount"] > 3) {
$content .= "<br>&nbsp;&nbsp;&nbsp;&nbsp;";
} else {
$content .= " ";
}
}
$content .= ' <span class="methodparam">';
$content .= '<span class="methodparam">';
++$this->params["count"];
if (isset($attrs[Reader::XMLNS_DOCBOOK]["rep"]) && $attrs[Reader::XMLNS_DOCBOOK]["rep"] == "repeat") {
$this->params["ellipsis"] = '...';
Expand Down
13 changes: 9 additions & 4 deletions phpdotnet/phd/Package/PHP/XHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,17 @@ public function format_varname_text($value, $tag) {

}

public function format_methodsynopsis($open, $name, $attrs) {
public function format_methodsynopsis($open, $name, $attrs, $props) {
if ($open) {
return parent::format_methodsynopsis($open, $name, $attrs);
return parent::format_methodsynopsis($open, $name, $attrs, $props);
}

$content = " )";
$content = "";
if ($this->params["paramCount"] > 3) {
$content .= "<br>";
}

$content .= ")";

if ($this->cchunk["methodsynopsis"]["returntypes"]) {
$types = [];
Expand All @@ -442,7 +447,7 @@ public function format_methodsynopsis($open, $name, $attrs) {
if (count($types) > 1) {
$type = '<span class="type">' . $type . '</span>';
}
$content .= ' : ' . $type;
$content .= ': ' . $type;
}

$content .= "</div>\n";
Expand Down
18 changes: 15 additions & 3 deletions phpdotnet/phd/Render.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,18 @@ public function execute(Reader $r) { /* {{{ */
$r->moveToElement();
}

$innerXml = null;
if ($r->name === "methodsynopsis" && $open) {
$innerXml = $r->readInnerXml();
}

$props = array(
"empty" => $r->isEmptyElement,
"isChunk" => false,
"lang" => $r->xmlLang,
"ns" => $r->namespaceURI,
"sibling" => $lastdepth >= $depth ? $this->STACK[$depth] : "",
"innerXml" => $innerXml,
"depth" => $depth,
);

Expand Down Expand Up @@ -160,12 +166,18 @@ public function execute(Reader $r) { /* {{{ */

case \XMLReader::WHITESPACE: /* {{{ */
case \XMLReader::SIGNIFICANT_WHITESPACE:
/* The following if is to skip whitespace before closing semicolon after property name */
if (in_array($this->STACK[$r->depth - 1], ["fieldsynopsis"], true) &&
in_array($this->STACK[$r->depth], ["varname"], true)

/* The following if is to skip unnecessary whitespaces in the parameter list */
if (in_array($this->STACK[$r->depth - 1], ['methodsynopsis', 'constructorsynopsis', 'destructorsynopsis'], true) &&
in_array($this->STACK[$r->depth], ["methodname", "methodparam", "type", "void"], true)
) {
break;
}

/* The following if is to skip whitespace before closing semicolon after property name */
if ($this->STACK[$r->depth - 1] === "fieldsynopsis" && $this->STACK[$r->depth] === "varname") {
break;
}
$retval = $r->value;
foreach($this as $format) {
$format->appendData($retval);
Expand Down