[phd] master: Allow linking to individual constants within a shared term (#273)
| From: | Jordi Kroon via GitHub | Date: | Sun, 22 Nov 2026 17:25:20 +0000 |
| Subject: | [phd] master: Allow linking to individual constants within a shared term (#273) | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-23992@lists.php.net to get a copy of this message | ||
Author: Jordi Kroon (jordikroon)
Committer: GitHub (web-flow)
Pusher: jordikroon
Date: 2026-11-22T18:25:17+01:00
Commit: https://github.com/php/phd/commit/f53b726d1d596020ce039a86df1f56667dd789ee
Raw diff: https://github.com/php/phd/commit/f53b726d1d596020ce039a86df1f56667dd789ee.diff
Allow linking to individual constants within a shared term (#273)
Changed paths:
M phpdotnet/phd/Package/Generic/XHTML.php
M tests/package/php/constant_links_001.phpt
M tests/package/php/data/constant_links.xml
Diff:
diff --git a/phpdotnet/phd/Package/Generic/XHTML.php b/phpdotnet/phd/Package/Generic/XHTML.php
index 3bd5973b0..734486de4 100644
--- a/phpdotnet/phd/Package/Generic/XHTML.php
+++ b/phpdotnet/phd/Package/Generic/XHTML.php
@@ -2122,6 +2122,9 @@ public function format_constant($open, $name, $attrs, $props)
$this->pushRole("constant_group");
$this->cchunk["constant"] = $props["innerXml"];
}
+ if (isset($attrs[Reader::XMLNS_XML]["id"])) {
+ return '<strong id="' . $attrs[Reader::XMLNS_XML]["id"]
. '"><code>';
+ }
return "<strong><code>";
}
diff --git a/tests/package/php/constant_links_001.phpt b/tests/package/php/constant_links_001.phpt
index e41ecb51c..7df5e537c 100644
--- a/tests/package/php/constant_links_001.phpt
+++ b/tests/package/php/constant_links_001.phpt
@@ -95,4 +95,20 @@ Content:
</p>
</div>
+ <div class="section">
+ <p class="para">5. Constants sharing a description have their own ID</p>
+ <dl>
+
+ <dt>
+ <strong
id="constant.first-alias"><code>FIRST_ALIAS</code></strong>,
+ <strong
id="constant.second-alias"><code>SECOND_ALIAS</code></strong>
+ (<span class="type"><a href="language.types.boolean.html"
class="type bool">bool</a></span>)
+ </dt>
+ <dd>
+ <p class="simpara">Shared description</p>
+ </dd>
+
+ </dl>
+ </div>
+
</div>
diff --git a/tests/package/php/data/constant_links.xml b/tests/package/php/data/constant_links.xml
index ea2b9f792..a83c0da36 100644
--- a/tests/package/php/data/constant_links.xml
+++ b/tests/package/php/data/constant_links.xml
@@ -36,4 +36,20 @@
</para>
</section>
+ <section>
+ <para>5. Constants sharing a description have their own ID</para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ <constant xml:id="constant.first-alias">FIRST_ALIAS</constant>,
+ <constant xml:id="constant.second-alias">SECOND_ALIAS</constant>
+ (<type>bool</type>)
+ </term>
+ <listitem>
+ <simpara>Shared description</simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+
</chapter>