Skip to content

Commit 4266e57

Browse files
committed
Tweak generated document
Do not emit a return value section for constructors and destructors Improve ID and refname generation for methods and support functions (?)
1 parent b004837 commit 4266e57

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

build/gen_stub.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,27 +1495,28 @@ public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?str
14951495
$refentry = $doc->createElement('refentry');
14961496
$doc->appendChild($refentry);
14971497

1498+
$id = $doc->createAttribute("xml:id");
14981499
if ($this->isMethod()) {
14991500
assert($this->name instanceof MethodName);
1500-
$id = $doc->createAttribute("xml:id");
1501-
$id->value = addslashes(strtolower($this->name->className->__toString())) . '.' . strtolower($this->name->methodName);
1502-
$refentry->appendChild($id);
1501+
/* Namespaces are seperated by '-', '_' must be converted to '-' too.
1502+
* Trim away the __ for magic methods */
1503+
$id->value = strtolower(
1504+
str_replace('\\', '-', $this->name->className->__toString())
1505+
. '.'
1506+
. str_replace('_', '-', ltrim($this->name->methodName, '_'))
1507+
);
15031508
} else {
1504-
// TODO Functions
1509+
$id->value = 'function.' . strtolower(str_replace('_', '-', $this->name->__toString()));
15051510
}
1511+
$refentry->appendChild($id);
15061512
$refentry->setAttribute("xmlns", "http://docbook.org/ns/docbook");
15071513
$refentry->appendChild(new DOMText("\n "));
15081514

15091515
/* Creation of <refnamediv> */
15101516
$refnamediv = $doc->createElement('refnamediv');
15111517
$refnamediv->appendChild(new DOMText("\n "));
1512-
if ($this->isMethod()) {
1513-
assert($this->name instanceof MethodName);
1514-
$refname = $doc->createElement('refname', $this->name->__toString());
1515-
$refnamediv->appendChild($refname);
1516-
} else {
1517-
// TODO Functions
1518-
}
1518+
$refname = $doc->createElement('refname', $this->name->__toString());
1519+
$refnamediv->appendChild($refname);
15191520
$refnamediv->appendChild(new DOMText("\n "));
15201521
$refpurpose = $doc->createElement('refpurpose', 'Description');
15211522
$refnamediv->appendChild($refpurpose);
@@ -1555,9 +1556,11 @@ public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?str
15551556
$refentry->appendChild(new DOMText("\n\n "));
15561557

15571558
/* Creation of <refsect1 role="returnvalues"> */
1558-
$returnRefSec = $this->getReturnValueSection($doc);
1559-
$refentry->appendChild($returnRefSec);
1560-
$refentry->appendChild(new DOMText("\n\n "));
1559+
if (!$this->name->isConstructor() && !$this->name->isDestructor()) {
1560+
$returnRefSec = $this->getReturnValueSection($doc);
1561+
$refentry->appendChild($returnRefSec);
1562+
$refentry->appendChild(new DOMText("\n\n "));
1563+
}
15611564

15621565
/* Creation of <refsect1 role="errors"> */
15631566
$errorsRefSec = $doc->createElement('refsect1');

0 commit comments

Comments
 (0)