Skip to content

Commit 2657a28

Browse files
authored
Merge pull request #66 from javiereguiluz/toctree_tweaks
Tweak the TOC Tree templates
2 parents 026d1a3 + 3118a8d commit 2657a28

File tree

6 files changed

+23
-22
lines changed

6 files changed

+23
-22
lines changed

src/Templates/default/html/toc-item.html.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
{% if tocItem.children|length %}
55
{% include "toc-level.html.twig" with {
6-
tocItems:tocItem.children
6+
tocItems: tocItem.children,
7+
toc_deep_level: toc_deep_level + 1
78
} %}
89
{% endif %}
910
</li>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% apply spaceless %}
2-
<ul>
2+
<ul class="toctree toctree-level-{{ toc_deep_level ?? 1 }} toctree-length-{{ tocItems|length }}">
33
{% for tocItem in tocItems %}
4-
{% include "toc-item.html.twig" %}
4+
{% include "toc-item.html.twig" with { toc_deep_level: 1 } %}
55
{% endfor %}
66
</ul>
77
{% endapply %}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% apply spaceless %}
2-
<div class="toctree-wrapper compound">
2+
<div class="toctree-wrapper">
33
{% include "toc-level.html.twig" %}
44
</div>
55
{% endapply %}

tests/fixtures/expected/build-pdf/book.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<h1 id="book-index-book">Book</h1>
77
<img src="_images/symfony-logo.png">
88
<p>Here is a link to the <a href="#index" class="reference internal">main index</a></p>
9-
<div class="toctree-wrapper compound">
10-
<ul>
9+
<div class="toctree-wrapper">
10+
<ul class="toctree toctree-level-1 toctree-length-2">
1111
<li><a href="https://symfony.com/doc/4.0/book/first-page.html#first-page">First page</a></li>
1212
<li><a href="https://symfony.com/doc/4.0/book/second-page.html#second-page">Second page</a></li>
1313
</ul>

tests/fixtures/expected/main/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ <h1 id="some-test-docs">
99
<a class="headerlink" href="#some-test-docs" title="Permalink to this headline">Some Test Docs!</a>
1010
</h1>
1111
<img src="_images/symfony-logo.png" />
12-
<div class="toctree-wrapper compound">
13-
<ul>
12+
<div class="toctree-wrapper">
13+
<ul class="toctree toctree-level-1 toctree-length-2">
1414
<li><a href="datetime.html#datetimetype-field">DateTimeType Field</a>
15-
<ul>
15+
<ul class="toctree toctree-level-2 toctree-length-4">
1616
<li><a href="datetime.html#field-options">Field Options</a></li>
1717
<li><a href="datetime.html#overridden-options">Overridden Options</a></li>
1818
<li><a href="datetime.html#field-variables">Field Variables</a></li>

tests/fixtures/expected/toctree/index.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,40 @@
66
<body>
77
<div class="section">
88
<h1 id="toctree"><a class="headerlink" href="#toctree" title="Permalink to this headline">Toctree</a></h1>
9-
<div class="toctree-wrapper compound">
10-
<ul>
9+
<div class="toctree-wrapper">
10+
<ul class="toctree toctree-level-1 toctree-length-1">
1111
<li><a href="file.html#title">Title</a>
12-
<ul>
12+
<ul class="toctree toctree-level-2 toctree-length-1">
1313
<li><a href="file.html#sub-title">Sub title</a></li>
1414
</ul>
1515
</li>
1616
</ul>
1717
</div>
18-
<div class="toctree-wrapper compound">
19-
<ul>
18+
<div class="toctree-wrapper">
19+
<ul class="toctree toctree-level-1 toctree-length-1">
2020
<li><a href="file.html#title">Title</a></li>
2121
</ul>
2222
</div>
23-
<div class="toctree-wrapper compound">
24-
<ul>
23+
<div class="toctree-wrapper">
24+
<ul class="toctree toctree-level-1 toctree-length-1">
2525
<li><a href="directory/another_file.html#another-file">Another file</a></li>
2626
</ul>
2727
</div>
28-
<div class="toctree-wrapper compound">
29-
<ul>
28+
<div class="toctree-wrapper">
29+
<ul class="toctree toctree-level-1 toctree-length-3">
3030
<li><a href="index.html#toctree">Toctree</a></li>
3131
<li><a href="directory/another_file.html#another-file">Another file</a></li>
3232
<li><a href="file.html#title">Title</a>
33-
<ul>
33+
<ul class="toctree toctree-level-2 toctree-length-1">
3434
<li><a href="file.html#sub-title">Sub title</a></li>
3535
</ul>
3636
</li>
3737
</ul>
3838
</div>
39-
<div class="toctree-wrapper compound">
40-
<ul>
39+
<div class="toctree-wrapper">
40+
<ul class="toctree toctree-level-1 toctree-length-3">
4141
<li><a href="file.html#title">Title</a>
42-
<ul>
42+
<ul class="toctree toctree-level-2 toctree-length-1">
4343
<li><a href="file.html#sub-title">Sub title</a></li>
4444
</ul>
4545
</li>

0 commit comments

Comments
 (0)