Skip to content

Commit 6929af3

Browse files
committed
[skip ci] Reviw + notes section
1 parent fe7f345 commit 6929af3

File tree

1 file changed

+73
-20
lines changed

1 file changed

+73
-20
lines changed

build/gen_stub.php

Lines changed: 73 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,18 @@ public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?str
15721572

15731573
/* Creation of <refsect1 role="errors"> */
15741574
$errorsRefSec = $this->generateRefSect1($doc, 'errors');
1575+
$errorsDescriptionParaConstantTag = $doc->createElement('constant');
1576+
$errorsDescriptionParaConstantTag->append("E_*");
1577+
$errorsDescriptionParaExceptionTag = $doc->createElement('exceptionname');
1578+
$errorsDescriptionParaExceptionTag->append("Exception");
15751579
$errorsDescriptionPara = $doc->createElement('para');
1576-
$errorsDescriptionPara->appendChild(new DOMText("\n When does this function issue E_* level errors, and/or throw exceptions.\n "));
1580+
$errorsDescriptionPara->append(
1581+
"\n When does this function issue ",
1582+
$errorsDescriptionParaConstantTag,
1583+
" level errors, and/or throw ",
1584+
$errorsDescriptionParaExceptionTag,
1585+
"s.\n "
1586+
);
15771587
$errorsRefSec->appendChild($errorsDescriptionPara);
15781588
$errorsRefSec->appendChild(new DOMText("\n "));
15791589

@@ -1583,28 +1593,51 @@ public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?str
15831593
$changelogRefSec = $this->getChangelogSection($doc);
15841594
$refentry->append($changelogRefSec, $REFSEC1_SEPERATOR);
15851595

1586-
$exampleRefSec = $this->getExampleSection($doc);
1596+
$exampleRefSec = $this->getExampleSection($doc, $id);
15871597
$refentry->append($exampleRefSec, $REFSEC1_SEPERATOR);
15881598

1589-
// TODO Notes section?
1599+
/* Creation of <refsect1 role="notes"> */
1600+
$notesRefSec = $this->generateRefSect1($doc, 'notes');
1601+
1602+
$noteTagSimara = $doc->createElement('simpara');
1603+
$noteTagSimara->append(
1604+
"\n Any notes that don't fit anywhere else should go here.\n "
1605+
);
1606+
$noteTag = $doc->createElement('note');
1607+
$noteTag->append("\n ", $noteTagSimara, "\n ");
1608+
$notesRefSec->append($noteTag, "\n ");
1609+
1610+
$refentry->append($notesRefSec, $REFSEC1_SEPERATOR);
15901611

15911612
/* Creation of <refsect1 role="seealso"> */
15921613
$seeAlsoRefSec = $this->generateRefSect1($doc, 'seealso');
15931614

1594-
/* TODO Actually generate a markup for class names, functions and links?
1595-
<simplelist>
1596-
<member><methodname>ClassName::otherMethodName</methodname></member>
1597-
<member><function>some_function</function></member>
1598-
<member>The <link linkend="something">something appendix</link></member>
1599-
</simplelist>
1600-
*/
1601-
$seeAlsoMember = $doc->createElement('member');
1602-
$seeAlsoMember->appendChild(new DOMText("Method name, function, or link to reference"));
1615+
$seeAlsoMemberClassMethod = $doc->createElement('member');
1616+
$seeAlsoMemberClassMethodTag = $doc->createElement('methodname');
1617+
$seeAlsoMemberClassMethodTag->appendChild(new DOMText("ClassName::otherMethodName"));
1618+
$seeAlsoMemberClassMethod->appendChild($seeAlsoMemberClassMethodTag);
1619+
1620+
$seeAlsoMemberFunction = $doc->createElement('member');
1621+
$seeAlsoMemberFunctionTag = $doc->createElement('function');
1622+
$seeAlsoMemberFunctionTag->appendChild(new DOMText("some_function"));
1623+
$seeAlsoMemberFunction->appendChild($seeAlsoMemberFunctionTag);
1624+
1625+
$seeAlsoMemberLink = $doc->createElement('member');
1626+
$seeAlsoMemberLinkTag = $doc->createElement('link');
1627+
$seeAlsoMemberLinkTag->setAttribute('linkend', 'some.id.chunk.to.link');
1628+
$seeAlsoMemberLinkTag->appendChild(new DOMText("something appendix"));
1629+
$seeAlsoMemberLink->appendChild($seeAlsoMemberLinkTag);
16031630

16041631
$seeAlsoList = $doc->createElement('simplelist');
1605-
$seeAlsoList->appendChild(new DOMText("\n "));
1606-
$seeAlsoList->appendChild($seeAlsoMember);
1607-
$seeAlsoList->appendChild(new DOMText("\n "));
1632+
$seeAlsoList->append(
1633+
"\n ",
1634+
$seeAlsoMemberClassMethod,
1635+
"\n ",
1636+
$seeAlsoMemberFunction,
1637+
"\n ",
1638+
$seeAlsoMemberLink,
1639+
"\n "
1640+
);
16081641

16091642
$seeAlsoRefSec->appendChild($seeAlsoList);
16101643
$seeAlsoRefSec->appendChild(new DOMText("\n "));
@@ -1709,12 +1742,28 @@ private function getReturnValueSection(DOMDocument $doc): DOMElement {
17091742
} else if (count($returnType->types) === 1) {
17101743
$type = $returnType->types[0];
17111744
$name = $type->name;
1745+
/*
17121746
$descriptionNode = match ($name) {
17131747
'void' => $doc->createEntityReference('return.void'),
17141748
'true' => $doc->createEntityReference('return.true.always'),
17151749
'bool' => $doc->createEntityReference('return.success'),
17161750
default => new DOMText("Description"),
17171751
};
1752+
*/
1753+
switch ($name) {
1754+
case 'void':
1755+
$descriptionNode = $doc->createEntityReference('return.void');
1756+
break;
1757+
case 'true':
1758+
$descriptionNode = $doc->createEntityReference('return.true.always');
1759+
break;
1760+
case 'bool':
1761+
$descriptionNode = $doc->createEntityReference('return.success');
1762+
break;
1763+
default:
1764+
$descriptionNode = new DOMText("Description");
1765+
break;
1766+
}
17181767
$returnDescriptionPara->appendChild($descriptionNode);
17191768
} else {
17201769
$returnDescriptionPara->appendChild(new DOMText("Description"));
@@ -1796,21 +1845,25 @@ private function getChangelogSection(DOMDocument $doc): DOMElement {
17961845
new DOMText('8.X.0'),
17971846
new DOMText("\n Description\n "),
17981847
]];
1799-
$table = $this->generateDocbookInformalTable($doc, indent: 2, columns: 2, headers: $headers, rows: $rows);
1848+
$table = $this->generateDocbookInformalTable(
1849+
$doc,
1850+
/* indent: */ 2,
1851+
/* columns: */ 2,
1852+
/* headers: */ $headers,
1853+
/* rows: */ $rows
1854+
);
18001855
$refSec->appendChild($table);
18011856

18021857
$refSec->appendChild(new DOMText("\n "));
18031858
return $refSec;
18041859
}
18051860

1806-
private function getExampleSection(DOMDocument $doc): DOMElement {
1861+
private function getExampleSection(DOMDocument $doc, string $id): DOMElement {
18071862
$refSec = $this->generateRefSect1($doc, 'examples');
18081863

18091864
$example = $doc->createElement('example');
18101865
$fnName = $this->name->__toString();
1811-
$fnNameForId = strtolower($fnName);
1812-
$fnNameForId = str_replace(['_', '\\', '::'], ['-', '-', '.'], $fnNameForId);
1813-
$example->setAttribute('xml:id', $fnNameForId . '.example.basic');
1866+
$example->setAttribute('xml:id', $id . '.example.basic');
18141867

18151868
$title = $doc->createElement('title');
18161869
$fn = $doc->createElement($this->isMethod() ? 'methodname' : 'function');

0 commit comments

Comments
 (0)