Skip to content

Commit

Permalink
[FEATURE] Show "Permalink to this definition" link (#40)
Browse files Browse the repository at this point in the history
As is shown by Sphinx.
  • Loading branch information
linawolf authored Mar 18, 2024
1 parent efe2239 commit 18ab5de
Show file tree
Hide file tree
Showing 51 changed files with 271 additions and 139 deletions.
1 change: 1 addition & 0 deletions resources/template/html/body/directive/php/case.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<dt class="sig sig-object php" id="{{ node.id }}">
<em class="property"><span class="pre">case</span></em>
{{ renderNode(node.memberName) }} : {% if node.backedValue -%}<span class="pre">{{ node.backedValue }}</span> {% endif -%}
{% include "body/directive/php/partials/linkToSnippet.html.twig" %}
</dt>
<dd>{{ renderNode(node.value) }}</dd>
</dl>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{%- endfor -%}
<em class="property"><span class="pre">{{ node.type }}</span> </em>
{{ renderNode(node.name) }} {%- if node.type == 'enum' and node.phpType -%}<span class="pre"> : {{ node.phpType }}</span> {% endif -%}
{% include "body/directive/php/partials/linkToSnippet.html.twig" %}
</dt>
<dd>
{{ renderNode(node.value) }}
Expand Down
1 change: 1 addition & 0 deletions resources/template/html/body/directive/php/const.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{% if node.phpType -%}<span class="pre">{{ node.phpType }}</span> {% endif -%}
<em class="property"><span class="pre">const</span></em>
{{ renderNode(node.memberName) }}
{% include "body/directive/php/partials/linkToSnippet.html.twig" %}
</dt>
<dd>{{ renderNode(node.value) }}</dd>
</dl>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
id="{{ node.id }}">
<em class="property"><span class="pre">global</span> </em>
<span class="pre">{{ node.name }}</span>
{% include "body/directive/php/partials/linkToSnippet.html.twig" %}
</dt>
<dd>
{{ renderNode(node.value) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{{- renderNode(modifier) }}{{ ' ' -}}
{%- endfor -%}
{{- renderNode(node.methodName) -}}
{% include "body/directive/php/partials/linkToSnippet.html.twig" %}
</dt>
<dd>
{{ renderNode(node.value) }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a class="headerlink" href="#{{ node.id }}" title="Permalink to this definition">¶</a>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{%- endfor -%}
{% if node.phpType -%}<span class="pre">{{ node.phpType }}</span> {% endif -%}
{{ renderNode(node.memberName) }}
{% include "body/directive/php/partials/linkToSnippet.html.twig" %}
</dt>
<dd>{{ renderNode(node.value) }}</dd>
</dl>
5 changes: 3 additions & 2 deletions tests/integration/class-abstract/expected/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- content start -->
<div class="section" id="abstract-class">
<h1>abstract class</h1>
<h1>abstract class</h1>

<dl class="php class">
<dt class="sig sig-object php"
Expand All @@ -9,7 +9,8 @@ <h1>abstract class</h1>
<em class="property"><span class="pre">class</span> </em>
<span class="sig-prename descclassname"><span class="pre">\TYPO3\CMS\Core\</span></span>
<span class="sig-name descname"><span class="pre">AbstractTest</span></span>
</dt>
<a class="headerlink" href="#typo3-cms-core-abstracttest" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Lorem Ipsum Dolor!</p>
</dd>
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/class-final-abstract/expected/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- content start -->
<div class="section" id="abstract-final-class-causes-warning">
<h1>abstract final class causes warning</h1>
<h1>abstract final class causes warning</h1>

<dl class="php class">
<dt class="sig sig-object php"
Expand All @@ -10,7 +10,8 @@ <h1>abstract final class causes warning</h1>
<em class="property"><span class="pre">class</span> </em>
<span class="sig-prename descclassname"><span class="pre">\TYPO3\CMS\Core\</span></span>
<span class="sig-name descname"><span class="pre">Test</span></span>
</dt>
<a class="headerlink" href="#typo3-cms-core-test" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Lorem Ipsum Dolor!</p>
</dd>
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/class-final/expected/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- content start -->
<div class="section" id="final-class">
<h1>final class</h1>
<h1>final class</h1>

<dl class="php class">
<dt class="sig sig-object php"
Expand All @@ -9,7 +9,8 @@ <h1>final class</h1>
<em class="property"><span class="pre">class</span> </em>
<span class="sig-prename descclassname"><span class="pre">\TYPO3\CMS\Core\</span></span>
<span class="sig-name descname"><span class="pre">Test</span></span>
</dt>
<a class="headerlink" href="#typo3-cms-core-test" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Lorem Ipsum Dolor!</p>
</dd>
Expand Down
11 changes: 7 additions & 4 deletions tests/integration/class-namespace-directive/expected/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<!-- content start -->
<div class="section" id="php-class-with-current-namespace-from-directive">
<h1>PHP Class with current namespace from directive</h1>
<h1>PHP Class with current namespace from directive</h1>

<dl class="php class">
<dt class="sig sig-object php"
id="typo3-cms-core-testclass">
<em class="property"><span class="pre">class</span> </em>
<span class="sig-prename descclassname"><span class="pre">\TYPO3\CMS\Core\</span></span>
<span class="sig-name descname"><span class="pre">TestClass</span></span>
</dt>
<a class="headerlink" href="#typo3-cms-core-testclass" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Lorem Ipsum Dolor!</p>
</dd>
Expand All @@ -20,7 +21,8 @@ <h1>PHP Class with current namespace from directive</h1>
<em class="property"><span class="pre">class</span> </em>
<span class="sig-prename descclassname"><span class="pre">\TYPO3\CMS\Core\</span></span>
<span class="sig-name descname"><span class="pre">AnotherClass</span></span>
</dt>
<a class="headerlink" href="#typo3-cms-core-anotherclass" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Lorem Ipsum Dolor Another!</p>
</dd>
Expand All @@ -32,7 +34,8 @@ <h1>PHP Class with current namespace from directive</h1>
<em class="property"><span class="pre">class</span> </em>
<span class="sig-prename descclassname"><span class="pre">\MyVendor\Some\Namespace\</span></span>
<span class="sig-name descname"><span class="pre">AnotherClass</span></span>
</dt>
<a class="headerlink" href="#myvendor-some-namespace-anotherclass" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Lorem Ipsum Dolor Yet Another!</p>
</dd>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<!-- content start -->
<div class="section" id="php-class-with-constants">
<h1>PHP class with constants</h1>
<h1>PHP class with constants</h1>

<dl class="php class">
<dt class="sig sig-object php"
id="chucklefactory-funclass">
<em class="property"><span class="pre">class</span> </em>
<span class="sig-prename descclassname"><span class="pre">\ChuckleFactory\</span></span>
<span class="sig-name descname"><span class="pre">FunClass</span></span>
</dt>
<a class="headerlink" href="#chucklefactory-funclass" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Where Fun Knows No Bounds!</p><dl class="php const">
<dt class="sig sig-object php" id="chucklefactory-funclass-joy-constant">
Expand All @@ -17,6 +18,7 @@ <h1>PHP class with constants</h1>
<em class="property"><span class="pre">const</span></em>
<span class="sig-name descname"><span class="pre">JOY_CONSTANT</span></span>

<a class="headerlink" href="#chucklefactory-funclass-joy-constant" title="Permalink to this definition"></a>
</dt>
<dd><p>The constant that encapsulates pure joy and laughter. Whenever you need
a pick-me-up, just access JOY_CONSTANT and let the chuckles begin.</p></dd>
Expand All @@ -28,6 +30,7 @@ <h1>PHP class with constants</h1>
<em class="property"><span class="pre">const</span></em>
<span class="sig-name descname"><span class="pre">GIGGLE_FACTOR</span></span>

<a class="headerlink" href="#chucklefactory-funclass-giggle-factor" title="Permalink to this definition"></a>
</dt>
<dd><p>A dynamic constant that measures the giggle intensity in the ChuckleFactory.
It&#039;s known to spontaneously increase during code reviews and coffee breaks.</p></dd>
Expand All @@ -39,6 +42,7 @@ <h1>PHP class with constants</h1>
<em class="property"><span class="pre">const</span></em>
<span class="sig-name descname"><span class="pre">WHIMSICAL_WONDER</span></span>

<a class="headerlink" href="#chucklefactory-funclass-whimsical-wonder" title="Permalink to this definition"></a>
</dt>
<dd><p>Unleash the power of whimsy! This constant is your key to unlocking the
whimsical wonders hidden within the FunClass. Expect surprises and delight!</p></dd>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<!-- content start -->
<div class="section" id="php-class-with-constants">
<h1>PHP class with constants</h1>
<h1>PHP class with constants</h1>

<dl class="php class">
<dt class="sig sig-object php"
id="secretsociety-enigmaticclass">
<em class="property"><span class="pre">class</span> </em>
<span class="sig-prename descclassname"><span class="pre">\SecretSociety\</span></span>
<span class="sig-name descname"><span class="pre">EnigmaticClass</span></span>
</dt>
<a class="headerlink" href="#secretsociety-enigmaticclass" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Unveiling the mysteries of constants!</p><dl class="php const">
<dt class="sig sig-object php" id="secretsociety-enigmaticclass-pi">
<span class="sig-name modifier"><span class="pre">public</span></span>
<em class="property"><span class="pre">const</span></em>
<span class="sig-name descname"><span class="pre">PI</span></span>

<a class="headerlink" href="#secretsociety-enigmaticclass-pi" title="Permalink to this definition"></a>
</dt>
<dd><p>The eternal symbol representing the ratio of a circle&#039;s circumference
to its diameter. Also used as the secret handshake among mathematicians.</p></dd>
Expand All @@ -26,6 +28,7 @@ <h1>PHP class with constants</h1>
<em class="property"><span class="pre">const</span></em>
<span class="sig-name descname"><span class="pre">SECRET_NUMBER</span></span>

<a class="headerlink" href="#secretsociety-enigmaticclass-secret-number" title="Permalink to this definition"></a>
</dt>
<dd><p>This constant holds the secret number known only to members of the
EnigmaticClass. Rumor has it, it&#039;s the combination to the ultimate
Expand All @@ -37,6 +40,7 @@ <h1>PHP class with constants</h1>
<em class="property"><span class="pre">const</span></em>
<span class="sig-name descname"><span class="pre">ETERNAL_FLAME</span></span>

<a class="headerlink" href="#secretsociety-enigmaticclass-eternal-flame" title="Permalink to this definition"></a>
</dt>
<dd><p>The eternal flame, kept alight by the power of mystical constants. Its
warmth is known only to those who dare to delve into the deepest realms
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/class-with-const-link/expected/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<!-- content start -->
<div class="section" id="php-class-with-constants">
<h1>PHP class with constants</h1>
<h1>PHP class with constants</h1>

<dl class="php class">
<dt class="sig sig-object php"
id="secretsociety-enigmaticclass">
<em class="property"><span class="pre">class</span> </em>
<span class="sig-prename descclassname"><span class="pre">\SecretSociety\</span></span>
<span class="sig-name descname"><span class="pre">EnigmaticClass</span></span>
</dt>
<a class="headerlink" href="#secretsociety-enigmaticclass" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Unveiling the mysteries of constants!</p><dl class="php const">
<dt class="sig sig-object php" id="secretsociety-enigmaticclass-pi">
<span class="sig-name modifier"><span class="pre">public</span></span>
<em class="property"><span class="pre">const</span></em>
<span class="sig-name descname"><span class="pre">PI</span></span>

<a class="headerlink" href="#secretsociety-enigmaticclass-pi" title="Permalink to this definition"></a>
</dt>
<dd><p>The eternal symbol representing the ratio of a circle&#039;s circumference
to its diameter. Also used as the secret handshake among mathematicians.</p></dd>
Expand All @@ -26,6 +28,7 @@ <h1>PHP class with constants</h1>
<em class="property"><span class="pre">const</span></em>
<span class="sig-name descname"><span class="pre">SECRET_NUMBER</span></span>

<a class="headerlink" href="#secretsociety-enigmaticclass-secret-number" title="Permalink to this definition"></a>
</dt>
<dd><p>This constant holds the secret number known only to members of the
EnigmaticClass. Rumor has it, it&#039;s the combination to the ultimate
Expand All @@ -37,6 +40,7 @@ <h1>PHP class with constants</h1>
<em class="property"><span class="pre">const</span></em>
<span class="sig-name descname"><span class="pre">ETERNAL_FLAME</span></span>

<a class="headerlink" href="#secretsociety-enigmaticclass-eternal-flame" title="Permalink to this definition"></a>
</dt>
<dd><p>The eternal flame, kept alight by the power of mystical constants. Its
warmth is known only to those who dare to delve into the deepest realms
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/class-with-const/expected/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<!-- content start -->
<div class="section" id="php-class-with-constants">
<h1>PHP class with constants</h1>
<h1>PHP class with constants</h1>

<dl class="php class">
<dt class="sig sig-object php"
id="secretsociety-enigmaticclass">
<em class="property"><span class="pre">class</span> </em>
<span class="sig-prename descclassname"><span class="pre">\SecretSociety\</span></span>
<span class="sig-name descname"><span class="pre">EnigmaticClass</span></span>
</dt>
<a class="headerlink" href="#secretsociety-enigmaticclass" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Unveiling the mysteries of constants!</p><dl class="php const">
<dt class="sig sig-object php" id="secretsociety-enigmaticclass-pi">
<span class="sig-name modifier"><span class="pre">public</span></span>
<em class="property"><span class="pre">const</span></em>
<span class="sig-name descname"><span class="pre">PI</span></span>

<a class="headerlink" href="#secretsociety-enigmaticclass-pi" title="Permalink to this definition"></a>
</dt>
<dd><p>The eternal symbol representing the ratio of a circle&#039;s circumference
to its diameter. Also used as the secret handshake among mathematicians.</p></dd>
Expand All @@ -26,6 +28,7 @@ <h1>PHP class with constants</h1>
<em class="property"><span class="pre">const</span></em>
<span class="sig-name descname"><span class="pre">SECRET_NUMBER</span></span>

<a class="headerlink" href="#secretsociety-enigmaticclass-secret-number" title="Permalink to this definition"></a>
</dt>
<dd><p>This constant holds the secret number known only to members of the
EnigmaticClass. Rumor has it, it&#039;s the combination to the ultimate
Expand All @@ -37,6 +40,7 @@ <h1>PHP class with constants</h1>
<em class="property"><span class="pre">const</span></em>
<span class="sig-name descname"><span class="pre">ETERNAL_FLAME</span></span>

<a class="headerlink" href="#secretsociety-enigmaticclass-eternal-flame" title="Permalink to this definition"></a>
</dt>
<dd><p>The eternal flame, kept alight by the power of mystical constants. Its
warmth is known only to those who dare to delve into the deepest realms
Expand Down
11 changes: 7 additions & 4 deletions tests/integration/class-with-link/expected/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<!-- content start -->
<div class="section" id="php-class-with-explicit-namespace">
<h1>PHP Class with explicit namespace</h1>
<h1>PHP Class with explicit namespace</h1>

<dl class="php class">
<dt class="sig sig-object php"
id="typo3-cms-core-test">
<em class="property"><span class="pre">class</span> </em>
<span class="sig-prename descclassname"><span class="pre">\TYPO3\CMS\Core\</span></span>
<span class="sig-name descname"><span class="pre">Test</span></span>
</dt>
<a class="headerlink" href="#typo3-cms-core-test" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Lorem Ipsum Dolor!</p><dl class="php method">
<dt class="sig sig-object php" id="typo3-cms-core-test-setdate">
<span class="sig-name descname"><span class="pre">setDate</span></span>
<span class="sig-paren">(</span>
<em class="sig-param"><span class="pre">int $year</span></em>, <em class="sig-param"><span class="pre">int $month</span></em>, <em class="sig-param"><span class="pre">int $day</span></em><span class="sig-paren">)</span>
</dt>
<a class="headerlink" href="#typo3-cms-core-test-setdate" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Set the date.</p>
</dd>
Expand All @@ -26,7 +28,8 @@ <h1>PHP Class with explicit namespace</h1>
<span class="sig-paren">(</span>
<span class="sig-paren">)</span>
<em class="sig-returns"><span class="pre">: int</span></em>
</dt>
<a class="headerlink" href="#typo3-cms-core-test-getdate" title="Permalink to this definition"></a>
</dt>
<dd>
<p>Get the date.</p>
</dd>
Expand Down
Loading

0 comments on commit 18ab5de

Please sign in to comment.