Skip to content

Commit d545130

Browse files
authored
Merge pull request #805 from phpDocumentor/bugfix/level-off
[BUGFIX] Correct Menu levels in global menu tree
2 parents 63223cf + 112a954 commit d545130

File tree

21 files changed

+52
-44
lines changed

21 files changed

+52
-44
lines changed

packages/guides-theme-bootstrap/resources/template/body/menu/mainmenu/menu.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{% if node.caption %}
33
<h2>{{ renderNode(node.caption) }}</h2>
44
{% endif %}
5-
<ul class="level-1">
5+
<ul class="menu-level-main">
66
{% for entry in node.menuEntries -%}
77
<li><a href="{{ renderLink(entry.url) }}"
88
class="nav-link {%- if node.currentPath == entry.url %} current {%- endif -%}{% if entry.url in node.rootlinePaths %} active {%- endif -%}"

packages/guides/src/Compiler/Passes/GlobalMenuPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ private function getMenuEntryWithChildren(CompilerContext $compilerContext, Menu
9797
return $menuEntry;
9898
}
9999

100-
$newMenuEntry = new InternalMenuEntryNode($menuEntry->getUrl(), $menuEntry->getValue(), [], false, 2);
100+
$newMenuEntry = new InternalMenuEntryNode($menuEntry->getUrl(), $menuEntry->getValue(), [], false, 1);
101101
$maxdepth = $this->settingsManager->getProjectSettings()->getMaxMenuDepth();
102102
$maxdepth = $maxdepth < 1 ? PHP_INT_MAX : $maxdepth + 1;
103103
$documentEntryOfMenuEntry = $compilerContext->getProjectNode()->getDocumentEntry($menuEntry->getUrl());
104-
$this->addSubEntries($compilerContext, $newMenuEntry, $documentEntryOfMenuEntry, 3, $maxdepth);
104+
$this->addSubEntries($compilerContext, $newMenuEntry, $documentEntryOfMenuEntry, 2, $maxdepth);
105105

106106
return $newMenuEntry;
107107
}
@@ -113,7 +113,7 @@ private function addSubEntries(
113113
int $currentLevel,
114114
int $maxDepth,
115115
): void {
116-
if ($maxDepth < $currentLevel) {
116+
if ($maxDepth <= $currentLevel) {
117117
return;
118118
}
119119

tests/Integration/tests-full/bootstrap/bootstrap-default-menu-several/expected/anotherPage.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<div class="col-lg-3">
6767
<nav class="nav flex-column">
6868
<h2>Main Menu</h2>
69-
<ul class="level-1">
69+
<ul class="menu-level-main">
7070
<li><a href="#"
7171
class="nav-link current active" aria-current="page" >
7272
Another Page
@@ -79,7 +79,7 @@ <h2>Main Menu</h2>
7979
class="nav-link">
8080
Subpages
8181
</a>
82-
<ul class="level-2">
82+
<ul class="level-1">
8383
<li><a href="subpages/subpage1.html"
8484
class="nav-link">
8585
Subpages 1
@@ -95,7 +95,7 @@ <h2>Main Menu</h2>
9595
</nav>
9696
<nav class="nav flex-column">
9797
<h2>Additional Menu</h2>
98-
<ul class="level-1">
98+
<ul class="menu-level-main">
9999
<li><a href="yetAnotherPage.html"
100100
class="nav-link">
101101
Yet Another Page

tests/Integration/tests-full/bootstrap/bootstrap-default-menu-several/expected/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<div class="col-lg-3">
6767
<nav class="nav flex-column">
6868
<h2>Main Menu</h2>
69-
<ul class="level-1">
69+
<ul class="menu-level-main">
7070
<li><a href="anotherPage.html"
7171
class="nav-link">
7272
Another Page
@@ -79,7 +79,7 @@ <h2>Main Menu</h2>
7979
class="nav-link">
8080
Subpages
8181
</a>
82-
<ul class="level-2">
82+
<ul class="level-1">
8383
<li><a href="subpages/subpage1.html"
8484
class="nav-link">
8585
Subpages 1
@@ -95,7 +95,7 @@ <h2>Main Menu</h2>
9595
</nav>
9696
<nav class="nav flex-column">
9797
<h2>Additional Menu</h2>
98-
<ul class="level-1">
98+
<ul class="menu-level-main">
9999
<li><a href="yetAnotherPage.html"
100100
class="nav-link">
101101
Yet Another Page

tests/Integration/tests-full/bootstrap/bootstrap-default-menu-several/expected/somePage.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<div class="col-lg-3">
6767
<nav class="nav flex-column">
6868
<h2>Main Menu</h2>
69-
<ul class="level-1">
69+
<ul class="menu-level-main">
7070
<li><a href="anotherPage.html"
7171
class="nav-link">
7272
Another Page
@@ -79,7 +79,7 @@ <h2>Main Menu</h2>
7979
class="nav-link">
8080
Subpages
8181
</a>
82-
<ul class="level-2">
82+
<ul class="level-1">
8383
<li><a href="subpages/subpage1.html"
8484
class="nav-link">
8585
Subpages 1
@@ -95,7 +95,7 @@ <h2>Main Menu</h2>
9595
</nav>
9696
<nav class="nav flex-column">
9797
<h2>Additional Menu</h2>
98-
<ul class="level-1">
98+
<ul class="menu-level-main">
9999
<li><a href="yetAnotherPage.html"
100100
class="nav-link">
101101
Yet Another Page

tests/Integration/tests-full/bootstrap/bootstrap-default-menu-several/expected/subpages/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<div class="col-lg-3">
6767
<nav class="nav flex-column">
6868
<h2>Main Menu</h2>
69-
<ul class="level-1">
69+
<ul class="menu-level-main">
7070
<li><a href="../anotherPage.html"
7171
class="nav-link">
7272
Another Page
@@ -79,7 +79,7 @@ <h2>Main Menu</h2>
7979
class="nav-link current active" aria-current="page" >
8080
Subpages
8181
</a>
82-
<ul class="level-2">
82+
<ul class="level-1">
8383
<li><a href="subpage1.html"
8484
class="nav-link">
8585
Subpages 1
@@ -95,7 +95,7 @@ <h2>Main Menu</h2>
9595
</nav>
9696
<nav class="nav flex-column">
9797
<h2>Additional Menu</h2>
98-
<ul class="level-1">
98+
<ul class="menu-level-main">
9999
<li><a href="../yetAnotherPage.html"
100100
class="nav-link">
101101
Yet Another Page

tests/Integration/tests-full/bootstrap/bootstrap-default-menu-several/expected/subpages/subpage1.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<div class="col-lg-3">
6767
<nav class="nav flex-column">
6868
<h2>Main Menu</h2>
69-
<ul class="level-1">
69+
<ul class="menu-level-main">
7070
<li><a href="../anotherPage.html"
7171
class="nav-link">
7272
Another Page
@@ -79,7 +79,7 @@ <h2>Main Menu</h2>
7979
class="nav-link active">
8080
Subpages
8181
</a>
82-
<ul class="level-2">
82+
<ul class="level-1">
8383
<li><a href="#"
8484
class="nav-link current active" aria-current="page">
8585
Subpages 1
@@ -95,7 +95,7 @@ <h2>Main Menu</h2>
9595
</nav>
9696
<nav class="nav flex-column">
9797
<h2>Additional Menu</h2>
98-
<ul class="level-1">
98+
<ul class="menu-level-main">
9999
<li><a href="../yetAnotherPage.html"
100100
class="nav-link">
101101
Yet Another Page

tests/Integration/tests-full/bootstrap/bootstrap-default-menu-several/expected/subpages/subpage2.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<div class="col-lg-3">
6767
<nav class="nav flex-column">
6868
<h2>Main Menu</h2>
69-
<ul class="level-1">
69+
<ul class="menu-level-main">
7070
<li><a href="../anotherPage.html"
7171
class="nav-link">
7272
Another Page
@@ -79,7 +79,7 @@ <h2>Main Menu</h2>
7979
class="nav-link active">
8080
Subpages
8181
</a>
82-
<ul class="level-2">
82+
<ul class="level-1">
8383
<li><a href="subpage1.html"
8484
class="nav-link">
8585
Subpages 1
@@ -95,7 +95,7 @@ <h2>Main Menu</h2>
9595
</nav>
9696
<nav class="nav flex-column">
9797
<h2>Additional Menu</h2>
98-
<ul class="level-1">
98+
<ul class="menu-level-main">
9999
<li><a href="../yetAnotherPage.html"
100100
class="nav-link">
101101
Yet Another Page

tests/Integration/tests-full/bootstrap/bootstrap-default-menu-several/expected/yetAnotherPage.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<div class="col-lg-3">
6767
<nav class="nav flex-column">
6868
<h2>Main Menu</h2>
69-
<ul class="level-1">
69+
<ul class="menu-level-main">
7070
<li><a href="anotherPage.html"
7171
class="nav-link">
7272
Another Page
@@ -79,7 +79,7 @@ <h2>Main Menu</h2>
7979
class="nav-link">
8080
Subpages
8181
</a>
82-
<ul class="level-2">
82+
<ul class="level-1">
8383
<li><a href="subpages/subpage1.html"
8484
class="nav-link">
8585
Subpages 1
@@ -95,7 +95,7 @@ <h2>Main Menu</h2>
9595
</nav>
9696
<nav class="nav flex-column">
9797
<h2>Additional Menu</h2>
98-
<ul class="level-1">
98+
<ul class="menu-level-main">
9999
<li><a href="#"
100100
class="nav-link current active" aria-current="page" >
101101
Yet Another Page

tests/Integration/tests-full/bootstrap/bootstrap-default-menu/expected/anotherPage.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<div class="row">
4848
<div class="col-lg-3">
4949
<nav class="nav flex-column">
50-
<ul class="level-1">
50+
<ul class="menu-level-main">
5151
<li><a href="/anotherPage.html"
5252
class="nav-link current active" aria-current="page" >
5353
Another Page

tests/Integration/tests-full/bootstrap/bootstrap-default-menu/expected/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<div class="row">
4848
<div class="col-lg-3">
4949
<nav class="nav flex-column">
50-
<ul class="level-1">
50+
<ul class="menu-level-main">
5151
<li><a href="/anotherPage.html"
5252
class="nav-link">
5353
Another Page

tests/Integration/tests-full/bootstrap/bootstrap-default-menu/expected/somePage.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<div class="row">
4848
<div class="col-lg-3">
4949
<nav class="nav flex-column">
50-
<ul class="level-1">
50+
<ul class="menu-level-main">
5151
<li><a href="/anotherPage.html"
5252
class="nav-link">
5353
Another Page

tests/Integration/tests-full/bootstrap/bootstrap-default-subpages-max-1/expected/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<div class="row">
4040
<div class="col-lg-3">
4141
<nav class="nav flex-column">
42-
<ul class="level-1">
42+
<ul class="menu-level-main">
4343
<li><a href="someDirectory/index.html"
4444
class="nav-link">
4545
Some Page

tests/Integration/tests-full/bootstrap/bootstrap-default-subpages-max-2/expected/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444
<div class="row">
4545
<div class="col-lg-3">
4646
<nav class="nav flex-column">
47-
<ul class="level-1">
47+
<ul class="menu-level-main">
4848
<li><a href="someDirectory/index.html"
4949
class="nav-link">
5050
Some Page
5151
</a>
52-
<ul class="level-2">
52+
<ul class="level-1">
5353
<li><a href="someDirectory/anotherDirectory/index.html"
5454
class="nav-link">
5555
Another Page

tests/Integration/tests-full/bootstrap/bootstrap-default-subpages-max-3/expected/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@
4444
<div class="row">
4545
<div class="col-lg-3">
4646
<nav class="nav flex-column">
47-
<ul class="level-1">
47+
<ul class="menu-level-main">
4848
<li><a href="someDirectory/index.html"
4949
class="nav-link">
5050
Some Page
5151
</a>
52-
<ul class="level-2">
52+
<ul class="level-1">
5353
<li><a href="someDirectory/anotherDirectory/index.html"
5454
class="nav-link">
5555
Another Page
5656
</a>
57-
<ul class="level-3">
57+
<ul class="level-2">
5858
<li><a href="someDirectory/anotherDirectory/yetAnotherDirectory/index.html"
5959
class="nav-link">
6060
Yet Another Page

tests/Integration/tests-full/bootstrap/bootstrap-default-subpages/expected/index.html

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,22 @@
4444
<div class="row">
4545
<div class="col-lg-3">
4646
<nav class="nav flex-column">
47-
<ul class="level-1">
47+
<ul class="menu-level-main">
4848
<li><a href="someDirectory/index.html"
4949
class="nav-link">
5050
Some Page
5151
</a>
52-
<ul class="level-2">
52+
<ul class="level-1">
5353
<li><a href="someDirectory/anotherDirectory/index.html"
5454
class="nav-link">
5555
Another Page
5656
</a>
57-
<ul class="level-3">
57+
<ul class="level-2">
5858
<li><a href="someDirectory/anotherDirectory/yetAnotherDirectory/index.html"
5959
class="nav-link">
6060
Yet Another Page
6161
</a>
62-
<ul class="level-4">
62+
<ul class="level-3">
6363
<li><a href="someDirectory/anotherDirectory/yetAnotherDirectory/andYetAnotherDirectory/index.html"
6464
class="nav-link">
6565
And Yet Another Page
@@ -93,7 +93,16 @@ <h1>Document Title</h1>
9393
<p>Lorem Ipsum Dolor.</p>
9494
<div class="toc">
9595
<ul class="menu-level">
96-
<li class="toc-item"><a href="someDirectory/index.html#some-page">Some Page</a></li>
96+
<li class="toc-item"><a href="someDirectory/index.html#some-page">Some Page</a> <ul class="menu-level-1">
97+
<li class="toc-item"><a href="someDirectory/anotherDirectory/index.html#another-page">Another Page</a> <ul class="menu-level-2">
98+
<li class="toc-item"><a href="someDirectory/anotherDirectory/yetAnotherDirectory/index.html#yet-another-page">Yet Another Page</a> <ul class="menu-level-3">
99+
<li class="toc-item"><a href="someDirectory/anotherDirectory/yetAnotherDirectory/andYetAnotherDirectory/index.html#and-yet-another-page">And Yet Another Page</a></li>
100+
101+
</ul></li>
102+
103+
</ul></li>
104+
105+
</ul></li>
97106

98107
</ul>
99108
</div>

tests/Integration/tests-full/bootstrap/bootstrap-default-subpages/input/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ Lorem Ipsum Dolor.
1414
.. toctree::
1515
:glob:
1616
:titlesonly:
17-
:maxdepth: 1
1817

1918
*/index

tests/Integration/tests-full/bootstrap/bootstrap-index/expected/anotherPage.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="rubric">Main Menu</div>
4949

5050
<nav class="nav flex-column">
51-
<ul class="level-1">
51+
<ul class="menu-level-main">
5252
<li><a href="/anotherPage.html"
5353
class="nav-link">
5454
Another Page

tests/Integration/tests-full/bootstrap/bootstrap-index/expected/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="rubric">Main Menu</div>
4949

5050
<nav class="nav flex-column">
51-
<ul class="level-1">
51+
<ul class="menu-level-main">
5252
<li><a href="/anotherPage.html"
5353
class="nav-link">
5454
Another Page

tests/Integration/tests-full/bootstrap/bootstrap-index/expected/somePage.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="rubric">Main Menu</div>
4949

5050
<nav class="nav flex-column">
51-
<ul class="level-1">
51+
<ul class="menu-level-main">
5252
<li><a href="/anotherPage.html"
5353
class="nav-link">
5454
Another Page

tests/Integration/tests-full/bootstrap/bootstrap-menu-external-linktargets/expected/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="col-lg-3">
4949
<nav class="nav flex-column">
5050
<h2>Some Caption</h2>
51-
<ul class="level-1">
51+
<ul class="menu-level-main">
5252
<li><a href="https://example.com/index.html#debug-settings"
5353
class="nav-link">
5454
Title

0 commit comments

Comments
 (0)