@@ -1572,8 +1572,18 @@ public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?str
1572
1572
1573
1573
/* Creation of <refsect1 role="errors"> */
1574
1574
$ errorsRefSec = $ this ->generateRefSect1 ($ doc , 'errors ' );
1575
+ $ errorsDescriptionParaConstantTag = $ doc ->createElement ('constant ' );
1576
+ $ errorsDescriptionParaConstantTag ->append ("E_* " );
1577
+ $ errorsDescriptionParaExceptionTag = $ doc ->createElement ('exceptionname ' );
1578
+ $ errorsDescriptionParaExceptionTag ->append ("Exception " );
1575
1579
$ 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
+ );
1577
1587
$ errorsRefSec ->appendChild ($ errorsDescriptionPara );
1578
1588
$ errorsRefSec ->appendChild (new DOMText ("\n " ));
1579
1589
@@ -1583,28 +1593,51 @@ public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?str
1583
1593
$ changelogRefSec = $ this ->getChangelogSection ($ doc );
1584
1594
$ refentry ->append ($ changelogRefSec , $ REFSEC1_SEPERATOR );
1585
1595
1586
- $ exampleRefSec = $ this ->getExampleSection ($ doc );
1596
+ $ exampleRefSec = $ this ->getExampleSection ($ doc, $ id );
1587
1597
$ refentry ->append ($ exampleRefSec , $ REFSEC1_SEPERATOR );
1588
1598
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 );
1590
1611
1591
1612
/* Creation of <refsect1 role="seealso"> */
1592
1613
$ seeAlsoRefSec = $ this ->generateRefSect1 ($ doc , 'seealso ' );
1593
1614
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 );
1603
1630
1604
1631
$ 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
+ );
1608
1641
1609
1642
$ seeAlsoRefSec ->appendChild ($ seeAlsoList );
1610
1643
$ seeAlsoRefSec ->appendChild (new DOMText ("\n " ));
@@ -1709,12 +1742,28 @@ private function getReturnValueSection(DOMDocument $doc): DOMElement {
1709
1742
} else if (count ($ returnType ->types ) === 1 ) {
1710
1743
$ type = $ returnType ->types [0 ];
1711
1744
$ name = $ type ->name ;
1745
+ /*
1712
1746
$descriptionNode = match ($name) {
1713
1747
'void' => $doc->createEntityReference('return.void'),
1714
1748
'true' => $doc->createEntityReference('return.true.always'),
1715
1749
'bool' => $doc->createEntityReference('return.success'),
1716
1750
default => new DOMText("Description"),
1717
1751
};
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
+ }
1718
1767
$ returnDescriptionPara ->appendChild ($ descriptionNode );
1719
1768
} else {
1720
1769
$ returnDescriptionPara ->appendChild (new DOMText ("Description " ));
@@ -1796,21 +1845,25 @@ private function getChangelogSection(DOMDocument $doc): DOMElement {
1796
1845
new DOMText ('8.X.0 ' ),
1797
1846
new DOMText ("\n Description \n " ),
1798
1847
]];
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
+ );
1800
1855
$ refSec ->appendChild ($ table );
1801
1856
1802
1857
$ refSec ->appendChild (new DOMText ("\n " ));
1803
1858
return $ refSec ;
1804
1859
}
1805
1860
1806
- private function getExampleSection(DOMDocument $ doc ): DOMElement {
1861
+ private function getExampleSection(DOMDocument $ doc, string $ id ): DOMElement {
1807
1862
$ refSec = $ this ->generateRefSect1 ($ doc , 'examples ' );
1808
1863
1809
1864
$ example = $ doc ->createElement ('example ' );
1810
1865
$ 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 ' );
1814
1867
1815
1868
$ title = $ doc ->createElement ('title ' );
1816
1869
$ fn = $ doc ->createElement ($ this ->isMethod () ? 'methodname ' : 'function ' );
0 commit comments