@@ -1483,6 +1483,17 @@ private function getFlagsAsArginfoString(): string
1483
1483
return $ flags ;
1484
1484
}
1485
1485
1486
+ private function generateRefSect1 (DOMDocument $ doc , string $ role ): DOMElement {
1487
+ $ refSec = $ doc ->createElement ('refsect1 ' );
1488
+ $ refSec ->setAttribute ('role ' , $ role );
1489
+ $ refSec ->append (
1490
+ "\n " ,
1491
+ $ doc ->createEntityReference ('reftitle. ' . $ role ),
1492
+ "\n "
1493
+ );
1494
+ return $ refSec ;
1495
+ }
1496
+
1486
1497
/**
1487
1498
* @param array<string, FuncInfo> $funcMap
1488
1499
* @param array<string, FuncInfo> $aliasMap
@@ -1531,12 +1542,7 @@ public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?str
1531
1542
$ refentry ->append ($ refnamediv , $ REFSEC1_SEPERATOR );
1532
1543
1533
1544
/* Creation of <refsect1 role="description"> */
1534
- $ descriptionRefSec = $ doc ->createElement ('refsect1 ' );
1535
- $ descriptionRefSec ->setAttribute ('role ' , 'description ' );
1536
- $ descriptionRefSec ->appendChild (new DOMText ("\n " ));
1537
- $ refTitleDescription = $ doc ->createEntityReference ('reftitle.description ' );
1538
- $ descriptionRefSec ->appendChild ($ refTitleDescription );
1539
- $ descriptionRefSec ->appendChild (new DOMText ("\n " ));
1545
+ $ descriptionRefSec = $ this ->generateRefSect1 ($ doc , 'description ' );
1540
1546
1541
1547
$ methodSynopsis = $ this ->getMethodSynopsisElement ($ funcMap , $ aliasMap , $ doc );
1542
1548
if (!$ methodSynopsis ) {
@@ -1565,12 +1571,7 @@ public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?str
1565
1571
}
1566
1572
1567
1573
/* Creation of <refsect1 role="errors"> */
1568
- $ errorsRefSec = $ doc ->createElement ('refsect1 ' );
1569
- $ errorsRefSec ->setAttribute ('role ' , 'errors ' );
1570
- $ errorsRefSec ->appendChild (new DOMText ("\n " ));
1571
- $ refTitleErrors = $ doc ->createEntityReference ('reftitle.errors ' );
1572
- $ errorsRefSec ->appendChild ($ refTitleErrors );
1573
- $ errorsRefSec ->appendChild (new DOMText ("\n " ));
1574
+ $ errorsRefSec = $ this ->generateRefSect1 ($ doc , 'errors ' );
1574
1575
$ errorsDescriptionPara = $ doc ->createElement ('para ' );
1575
1576
$ errorsDescriptionPara ->appendChild (new DOMText ("\n When does this function issue E_* level errors, and/or throw exceptions. \n " ));
1576
1577
$ errorsRefSec ->appendChild ($ errorsDescriptionPara );
@@ -1582,17 +1583,13 @@ public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?str
1582
1583
$ changelogRefSec = $ this ->getChangelogSection ($ doc );
1583
1584
$ refentry ->append ($ changelogRefSec , $ REFSEC1_SEPERATOR );
1584
1585
1585
- // TODO Examples, and Notes sections
1586
1586
$ exampleRefSec = $ this ->getExampleSection ($ doc );
1587
1587
$ refentry ->append ($ exampleRefSec , $ REFSEC1_SEPERATOR );
1588
1588
1589
+ // TODO Notes section?
1590
+
1589
1591
/* Creation of <refsect1 role="seealso"> */
1590
- $ seeAlsoRefSec = $ doc ->createElement ('refsect1 ' );
1591
- $ seeAlsoRefSec ->setAttribute ('role ' , 'seealso ' );
1592
- $ seeAlsoRefSec ->appendChild (new DOMText ("\n " ));
1593
- $ refTitleSeeAlso = $ doc ->createEntityReference ('reftitle.seealso ' );
1594
- $ seeAlsoRefSec ->appendChild ($ refTitleSeeAlso );
1595
- $ seeAlsoRefSec ->appendChild (new DOMText ("\n " ));
1592
+ $ seeAlsoRefSec = $ this ->generateRefSect1 ($ doc , 'seealso ' );
1596
1593
1597
1594
/* TODO Actually generate a markup for class names, functions and links?
1598
1595
<simplelist>
@@ -1644,12 +1641,7 @@ public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?str
1644
1641
}
1645
1642
1646
1643
private function getParameterSection (DOMDocument $ doc ): DOMElement {
1647
- $ parametersRefSec = $ doc ->createElement ('refsect1 ' );
1648
- $ parametersRefSec ->setAttribute ('role ' , 'parameters ' );
1649
- $ parametersRefSec ->appendChild (new DOMText ("\n " ));
1650
- $ refTitle = $ doc ->createEntityReference ('reftitle.parameters ' );
1651
- $ parametersRefSec ->appendChild ($ refTitle );
1652
- $ parametersRefSec ->appendChild (new DOMText ("\n " ));
1644
+ $ parametersRefSec = $ this ->generateRefSect1 ($ doc , 'parameters ' );
1653
1645
if (empty ($ this ->args )) {
1654
1646
$ noParamEntity = $ doc ->createEntityReference ('no.function.parameters ' );
1655
1647
$ parametersRefSec ->appendChild ($ noParamEntity );
@@ -1706,12 +1698,8 @@ private function getParameterSection(DOMDocument $doc): DOMElement {
1706
1698
}
1707
1699
1708
1700
private function getReturnValueSection (DOMDocument $ doc ): DOMElement {
1709
- $ returnRefSec = $ doc ->createElement ('refsect1 ' );
1710
- $ returnRefSec ->setAttribute ('role ' , 'returnvalues ' );
1711
- $ returnRefSec ->appendChild (new DOMText ("\n " ));
1712
- $ refTitle = $ doc ->createEntityReference ('reftitle.returnvalues ' );
1713
- $ returnRefSec ->appendChild ($ refTitle );
1714
- $ returnRefSec ->appendChild (new DOMText ("\n " ));
1701
+ $ returnRefSec = $ this ->generateRefSect1 ($ doc , 'returnvalues ' );
1702
+
1715
1703
$ returnDescriptionPara = $ doc ->createElement ('para ' );
1716
1704
$ returnDescriptionPara ->appendChild (new DOMText ("\n " ));
1717
1705
@@ -1799,12 +1787,7 @@ private function generateDocbookInformalTable(
1799
1787
}
1800
1788
1801
1789
private function getChangelogSection (DOMDocument $ doc ): DOMElement {
1802
- $ refSec = $ doc ->createElement ('refsect1 ' );
1803
- $ refSec ->setAttribute ('role ' , 'changelog ' );
1804
- $ refSec ->appendChild (new DOMText ("\n " ));
1805
- $ refTitle = $ doc ->createEntityReference ('reftitle.changelog ' );
1806
- $ refSec ->appendChild ($ refTitle );
1807
- $ refSec ->appendChild (new DOMText ("\n " ));
1790
+ $ refSec = $ this ->generateRefSect1 ($ doc , 'changelog ' );
1808
1791
$ headers = [
1809
1792
$ doc ->createEntityReference ('Version ' ),
1810
1793
$ doc ->createEntityReference ('Description ' ),
@@ -1821,10 +1804,7 @@ private function getChangelogSection(DOMDocument $doc): DOMElement {
1821
1804
}
1822
1805
1823
1806
private function getExampleSection(DOMDocument $ doc ): DOMElement {
1824
- $ refSec = $ doc ->createElement ('refsect1 ' );
1825
- $ refSec ->setAttribute ('role ' , 'examples ' );
1826
- $ refTitle = $ doc ->createEntityReference ('reftitle.examples ' );
1827
- $ refSec ->append ("\n " , $ refTitle );
1807
+ $ refSec = $ this ->generateRefSect1 ($ doc , 'examples ' );
1828
1808
1829
1809
$ example = $ doc ->createElement ('example ' );
1830
1810
$ example ->setAttribute ('xml:id ' , 'func-or-method-name.example.basic ' );
@@ -1873,7 +1853,7 @@ private function getExampleSection(DOMDocument $doc): DOMElement {
1873
1853
$example->append("\n ", $screen);
1874
1854
$example->append("\n ");
1875
1855
1876
- $refSec->append("\n ", $example);
1856
+ $refSec->append($example);
1877
1857
1878
1858
$refSec->appendChild(new DOMText("\n "));
1879
1859
return $refSec;
0 commit comments