Skip to content

Commit ae8605d

Browse files
authored
[TASK] Allow other nodes in confval menu (#599)
This enables us to keep headlines in between with the rubric directive and to keep anchors functioning.
1 parent fc95df0 commit ae8605d

File tree

5 files changed

+214
-27
lines changed

5 files changed

+214
-27
lines changed

packages/typo3-docs-theme/resources/template/body/directive/confval-menu.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,9 @@
164164
</div>
165165
{% endif %}
166166
{% for child in node.children %}
167-
{% include "body/directive/confval.html.twig" with {'node': child, 'backAnchor': node.anchor } %}
167+
{% if child.isConfval %}
168+
{% include "body/directive/confval.html.twig" with {'node': child, 'backAnchor': node.anchor } %}
169+
{% else %}
170+
{{ renderNode(child) }}
171+
{% endif %}
168172
{% endfor %}

packages/typo3-docs-theme/src/Directives/ConfvalMenuDirective.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use phpDocumentor\Guides\RestructuredText\Parser\Directive;
2424
use phpDocumentor\Guides\RestructuredText\Parser\Productions\Rule;
2525
use phpDocumentor\Guides\RestructuredText\TextRoles\GenericLinkProvider;
26-
use Psr\Log\LoggerInterface;
2726
use T3Docs\Typo3DocsTheme\Nodes\ConfvalMenuNode;
2827

2928
class ConfvalMenuDirective extends SubDirective
@@ -32,7 +31,6 @@ class ConfvalMenuDirective extends SubDirective
3231
public function __construct(
3332
Rule $startingRule,
3433
GenericLinkProvider $genericLinkProvider,
35-
private readonly LoggerInterface $logger,
3634
private readonly AnchorNormalizer $anchorReducer,
3735
) {
3836
parent::__construct($startingRule);
@@ -47,9 +45,8 @@ protected function processSub(
4745
$childConfvals = [];
4846
foreach ($originalChildren as $child) {
4947
if ($child instanceof ConfvalNode) {
48+
$child = $child->withOptions(array_merge($child->getOptions(), ['isConfval' => true]));
5049
$childConfvals[] = $child;
51-
} else {
52-
$this->logger->warning('A confval-menu may only contain confvals. ', $blockContext->getLoggerInformation());
5350
}
5451
}
5552
$fields = [];
@@ -84,7 +81,7 @@ protected function processSub(
8481
$id,
8582
$directive->getData(),
8683
$directive->getDataNode() ?? new InlineCompoundNode(),
87-
$childConfvals,
84+
$originalChildren,
8885
$directive->getOptionString('caption'),
8986
$childConfvals,
9087
$fields,
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<!-- content start -->
2+
<section class="section" id="confval">
3+
<h1>Confval<a class="headerlink" href="#confval" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
4+
5+
6+
7+
8+
<div class="table-responsive confval-table" id="confval-menu-case-properties">
9+
<table class="table table-hover caption-top"><caption>Properties of CASE</caption> <thead>
10+
<tr>
11+
<th scope="col">Name</th>
12+
13+
<th scope="col">Type</th>
14+
</tr>
15+
</thead>
16+
<tr>
17+
<td><div class="confval-label ps-0"><a href="#confval-case-array">array of cObjects</a></div></td>
18+
<td>cObject</td>
19+
</tr>
20+
21+
<tr>
22+
<td><div class="confval-label ps-0"><a href="#confval-case-cache">cache</a></div></td>
23+
<td>cache</td>
24+
</tr>
25+
26+
<tr>
27+
<td><div class="confval-label ps-0"><a href="#confval-case-default">default</a></div></td>
28+
<td>cObject</td>
29+
</tr>
30+
31+
<tr>
32+
<td><div class="confval-label ps-0"><a href="#confval-case-if">if</a></div></td>
33+
<td>-&gt;if</td>
34+
</tr>
35+
36+
</table>
37+
</div>
38+
<a id="case-array"></a>
39+
<dl class="confval">
40+
<dt id="confval-case-array" class="d-flex justify-content-between">
41+
<div class="confval-header">
42+
<code class="sig-name descname"><span class="pre">array of cObjects</span></code>
43+
<a class="headerlink" href="#confval-case-array" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" data-id="confval-case-array" data-rstCode=":confval:`array of cObjects &lt;somemanual:case-array&gt;`" title="Reference this configuration value"></a>
44+
</div>
45+
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
46+
</dt>
47+
<dd>
48+
<dl class="field-list simple">
49+
<dt class="field-even">Type</dt>
50+
<dd class="field-even">cObject
51+
</dd>
52+
</dl>
53+
<div class="confval-description">
54+
55+
<p>Array of cObjects. Use this to define cObjects for the different
56+
values of <code>cobj-case-key</code>. If <code>cobj-case-key</code> has a certain value,
57+
the according cObject will be rendered. The cObjects can have any name, but not
58+
the names of the other properties of the cObject CASE.</p>
59+
60+
</div>
61+
</dd>
62+
</dl>
63+
<a id="case-cache"></a>
64+
<dl class="confval">
65+
<dt id="confval-case-cache" class="d-flex justify-content-between">
66+
<div class="confval-header">
67+
<code class="sig-name descname"><span class="pre">cache</span></code>
68+
<a class="headerlink" href="#confval-case-cache" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" data-id="confval-case-cache" data-rstCode=":confval:`cache &lt;somemanual:case-cache&gt;`" title="Reference this configuration value"></a>
69+
</div>
70+
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
71+
</dt>
72+
<dd>
73+
<dl class="field-list simple">
74+
<dt class="field-even">Type</dt>
75+
<dd class="field-even">cache
76+
</dd>
77+
</dl>
78+
<div class="confval-description">
79+
80+
<p>See for details.</p>
81+
82+
</div>
83+
</dd>
84+
</dl>
85+
<a id="case-default"></a>
86+
<dl class="confval">
87+
<dt id="confval-case-default" class="d-flex justify-content-between">
88+
<div class="confval-header">
89+
<code class="sig-name descname"><span class="pre">default</span></code>
90+
<a class="headerlink" href="#confval-case-default" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" data-id="confval-case-default" data-rstCode=":confval:`default &lt;somemanual:case-default&gt;`" title="Reference this configuration value"></a>
91+
</div>
92+
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
93+
</dt>
94+
<dd>
95+
<dl class="field-list simple">
96+
<dt class="field-even">Type</dt>
97+
<dd class="field-even">cObject
98+
</dd>
99+
</dl>
100+
<div class="confval-description">
101+
102+
<p>Use this to define the rendering for <em>those</em> values of cobj-case-key that
103+
do <em>not</em> match any of the values of the cobj-case-array-of-cObjects. If no
104+
default cObject is defined, an empty string will be returned for
105+
the default case.</p>
106+
107+
</div>
108+
</dd>
109+
</dl>
110+
<div class="rubric h2">Conditions</div>
111+
<a id="case-if"></a>
112+
<dl class="confval">
113+
<dt id="confval-case-if" class="d-flex justify-content-between">
114+
<div class="confval-header">
115+
<code class="sig-name descname"><span class="pre">if</span></code>
116+
<a class="headerlink" href="#confval-case-if" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" data-id="confval-case-if" data-rstCode=":confval:`if &lt;somemanual:case-if&gt;`" title="Reference this configuration value"></a>
117+
</div>
118+
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
119+
</dt>
120+
<dd>
121+
<dl class="field-list simple">
122+
<dt class="field-even">Type</dt>
123+
<dd class="field-even">-&gt;if
124+
</dd>
125+
</dl>
126+
<div class="confval-description">
127+
128+
<p>If if returns false, nothing is returned.</p>
129+
130+
</div>
131+
</dd>
132+
</dl>
133+
134+
</section>
135+
<!-- content end -->
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
=======
2+
Confval
3+
=======
4+
5+
6+
.. confval-menu::
7+
:name: case-properties
8+
:caption: Properties of CASE
9+
:display: table
10+
:type:
11+
12+
.. _case-array:
13+
14+
.. confval:: array of cObjects
15+
:name: case-array
16+
:type: cObject
17+
18+
Array of cObjects. Use this to define cObjects for the different
19+
values of `cobj-case-key`. If `cobj-case-key` has a certain value,
20+
the according cObject will be rendered. The cObjects can have any name, but not
21+
the names of the other properties of the cObject CASE.
22+
23+
.. _case-cache:
24+
25+
.. confval:: cache
26+
:name: case-cache
27+
:type: cache
28+
29+
See for details.
30+
31+
.. _case-default:
32+
33+
.. confval:: default
34+
:name: case-default
35+
:type: cObject
36+
37+
Use this to define the rendering for *those* values of cobj-case-key that
38+
do *not* match any of the values of the cobj-case-array-of-cObjects. If no
39+
default cObject is defined, an empty string will be returned for
40+
the default case.
41+
42+
.. rubric:: Conditions
43+
:class: h2
44+
45+
.. _case-if:
46+
47+
.. confval:: if
48+
:name: case-if
49+
:type: ->if
50+
51+
If if returns false, nothing is returned.

tests/Integration/tests/confval/confval-menu-tree-multiple/expected/index.html

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@ <h2>Properties of CASE<a class="headerlink" href="#properties-of-case" data-bs-t
4040

4141
</table>
4242
</div>
43-
<dl class="confval">
43+
<dl class="confval">
4444
<dt id="confval-case-array" class="d-flex justify-content-between">
4545
<div class="confval-header">
4646
<code class="sig-name descname"><span class="pre">array of cObjects</span></code>
4747
<a class="headerlink" href="#confval-case-array" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" data-id="confval-case-array" data-rstCode=":confval:`array of cObjects &lt;somemanual:case-array&gt;`" title="Reference this configuration value"></a>
4848
</div>
49-
<div class="confval-back-to-top"> <a href="#confval-menu-case-properties" class="backToList" title="Back to list"><i class="fa-solid fa-angles-up fa-xs"></i></a>
50-
</div>
49+
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
5150
</dt>
5251
<dd>
5352
<dl class="field-list simple">
@@ -64,14 +63,14 @@ <h2>Properties of CASE<a class="headerlink" href="#properties-of-case" data-bs-t
6463

6564
</div>
6665
</dd>
67-
</dl> <dl class="confval">
66+
</dl>
67+
<dl class="confval">
6868
<dt id="confval-case-cache" class="d-flex justify-content-between">
6969
<div class="confval-header">
7070
<code class="sig-name descname"><span class="pre">cache</span></code>
7171
<a class="headerlink" href="#confval-case-cache" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" data-id="confval-case-cache" data-rstCode=":confval:`cache &lt;somemanual:case-cache&gt;`" title="Reference this configuration value"></a>
7272
</div>
73-
<div class="confval-back-to-top"> <a href="#confval-menu-case-properties" class="backToList" title="Back to list"><i class="fa-solid fa-angles-up fa-xs"></i></a>
74-
</div>
73+
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
7574
</dt>
7675
<dd>
7776
<dl class="field-list simple">
@@ -85,14 +84,14 @@ <h2>Properties of CASE<a class="headerlink" href="#properties-of-case" data-bs-t
8584

8685
</div>
8786
</dd>
88-
</dl> <dl class="confval">
87+
</dl>
88+
<dl class="confval">
8989
<dt id="confval-case-default" class="d-flex justify-content-between">
9090
<div class="confval-header">
9191
<code class="sig-name descname"><span class="pre">default</span></code>
9292
<a class="headerlink" href="#confval-case-default" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" data-id="confval-case-default" data-rstCode=":confval:`default &lt;somemanual:case-default&gt;`" title="Reference this configuration value"></a>
9393
</div>
94-
<div class="confval-back-to-top"> <a href="#confval-menu-case-properties" class="backToList" title="Back to list"><i class="fa-solid fa-angles-up fa-xs"></i></a>
95-
</div>
94+
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
9695
</dt>
9796
<dd>
9897
<dl class="field-list simple">
@@ -109,14 +108,14 @@ <h2>Properties of CASE<a class="headerlink" href="#properties-of-case" data-bs-t
109108

110109
</div>
111110
</dd>
112-
</dl> <dl class="confval">
111+
</dl>
112+
<dl class="confval">
113113
<dt id="confval-case-if" class="d-flex justify-content-between">
114114
<div class="confval-header">
115115
<code class="sig-name descname"><span class="pre">if</span></code>
116116
<a class="headerlink" href="#confval-case-if" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" data-id="confval-case-if" data-rstCode=":confval:`if &lt;somemanual:case-if&gt;`" title="Reference this configuration value"></a>
117117
</div>
118-
<div class="confval-back-to-top"> <a href="#confval-menu-case-properties" class="backToList" title="Back to list"><i class="fa-solid fa-angles-up fa-xs"></i></a>
119-
</div>
118+
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
120119
</dt>
121120
<dd>
122121
<dl class="field-list simple">
@@ -131,6 +130,7 @@ <h2>Properties of CASE<a class="headerlink" href="#properties-of-case" data-bs-t
131130
</div>
132131
</dd>
133132
</dl>
133+
134134
</section>
135135
<section class="section" id="properties-of-coa">
136136
<h2>Properties of COA<a class="headerlink" href="#properties-of-coa" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h2>
@@ -163,14 +163,13 @@ <h2>Properties of COA<a class="headerlink" href="#properties-of-coa" data-bs-tog
163163

164164
</table>
165165
</div>
166-
<dl class="confval">
166+
<dl class="confval">
167167
<dt id="confval-coa-array" class="d-flex justify-content-between">
168168
<div class="confval-header">
169169
<code class="sig-name descname"><span class="pre">1,2,3,4...</span></code>
170170
<a class="headerlink" href="#confval-coa-array" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" data-id="confval-coa-array" data-rstCode=":confval:`1,2,3,4... &lt;somemanual:coa-array&gt;`" title="Reference this configuration value"></a>
171171
</div>
172-
<div class="confval-back-to-top"> <a href="#confval-menu-coa-properties" class="backToList" title="Back to list"><i class="fa-solid fa-angles-up fa-xs"></i></a>
173-
</div>
172+
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
174173
</dt>
175174
<dd>
176175
<dl class="field-list simple">
@@ -185,14 +184,14 @@ <h2>Properties of COA<a class="headerlink" href="#properties-of-coa" data-bs-tog
185184

186185
</div>
187186
</dd>
188-
</dl> <dl class="confval">
187+
</dl>
188+
<dl class="confval">
189189
<dt id="confval-coa-cache" class="d-flex justify-content-between">
190190
<div class="confval-header">
191191
<code class="sig-name descname"><span class="pre">cache</span></code>
192192
<a class="headerlink" href="#confval-coa-cache" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" data-id="confval-coa-cache" data-rstCode=":confval:`cache &lt;somemanual:coa-cache&gt;`" title="Reference this configuration value"></a>
193193
</div>
194-
<div class="confval-back-to-top"> <a href="#confval-menu-coa-properties" class="backToList" title="Back to list"><i class="fa-solid fa-angles-up fa-xs"></i></a>
195-
</div>
194+
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
196195
</dt>
197196
<dd>
198197
<dl class="field-list simple">
@@ -206,14 +205,14 @@ <h2>Properties of COA<a class="headerlink" href="#properties-of-coa" data-bs-tog
206205

207206
</div>
208207
</dd>
209-
</dl> <dl class="confval">
208+
</dl>
209+
<dl class="confval">
210210
<dt id="confval-coa-if" class="d-flex justify-content-between">
211211
<div class="confval-header">
212212
<code class="sig-name descname"><span class="pre">if</span></code>
213213
<a class="headerlink" href="#confval-coa-if" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" data-id="confval-coa-if" data-rstCode=":confval:`if &lt;somemanual:coa-if&gt;`" title="Reference this configuration value"></a>
214214
</div>
215-
<div class="confval-back-to-top"> <a href="#confval-menu-coa-properties" class="backToList" title="Back to list"><i class="fa-solid fa-angles-up fa-xs"></i></a>
216-
</div>
215+
<div class="confval-back-to-top"> <a href="#" class="backToTop" title="Back to top"><i class="fa-solid fa-arrow-up fa-xs"></i></a> </div>
217216
</dt>
218217
<dd>
219218
<dl class="field-list simple">
@@ -228,6 +227,7 @@ <h2>Properties of COA<a class="headerlink" href="#properties-of-coa" data-bs-tog
228227
</div>
229228
</dd>
230229
</dl>
230+
231231
</section>
232232
</section>
233233
<!-- content end -->

0 commit comments

Comments
 (0)