diff --git a/packages/guides/src/Compiler/NodeTransformers/MenuNodeTransformers/SubInternalMenuEntryNodeTransformer.php b/packages/guides/src/Compiler/NodeTransformers/MenuNodeTransformers/SubInternalMenuEntryNodeTransformer.php index 9aa777608..92c133635 100644 --- a/packages/guides/src/Compiler/NodeTransformers/MenuNodeTransformers/SubInternalMenuEntryNodeTransformer.php +++ b/packages/guides/src/Compiler/NodeTransformers/MenuNodeTransformers/SubInternalMenuEntryNodeTransformer.php @@ -53,7 +53,6 @@ protected function handleMenuEntry(MenuNode $currentMenu, MenuEntryNode $entryNo return []; } - $documentEntryOfMenuEntry = $compilerContext->getProjectNode()->getDocumentEntry($entryNode->getUrl()); $this->addSubEntries($currentMenu, $compilerContext, $entryNode, $documentEntryOfMenuEntry, $entryNode->getLevel() + 1, $maxDepth); return [$entryNode]; @@ -79,9 +78,15 @@ private function addSubEntries( foreach ($documentEntry->getMenuEntries() as $subEntryNode) { if ($subEntryNode instanceof DocumentEntryNode) { + $titleNode = $subEntryNode->getTitle(); + $navigationTitle = $subEntryNode->getAdditionalData('navigationTitle'); + if ($navigationTitle instanceof TitleNode) { + $titleNode = $navigationTitle; + } + $subMenuEntry = new InternalMenuEntryNode( $subEntryNode->getFile(), - $subEntryNode->getTitle(), + $titleNode, [], false, $currentLevel, diff --git a/packages/guides/src/Compiler/Passes/GlobalMenuPass.php b/packages/guides/src/Compiler/Passes/GlobalMenuPass.php index edc97ba8a..b1891d7e2 100644 --- a/packages/guides/src/Compiler/Passes/GlobalMenuPass.php +++ b/packages/guides/src/Compiler/Passes/GlobalMenuPass.php @@ -158,9 +158,15 @@ private function addSubEntries( private function createInternalMenuEntry(DocumentEntryNode $subEntryNode, int $currentLevel): InternalMenuEntryNode { + $titleNode = $subEntryNode->getTitle(); + $navigationTitle = $subEntryNode->getAdditionalData('navigationTitle'); + if ($navigationTitle instanceof TitleNode) { + $titleNode = $navigationTitle; + } + return new InternalMenuEntryNode( $subEntryNode->getFile(), - $subEntryNode->getTitle(), + $titleNode, [], false, $currentLevel, diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 4cb95d134..c6b80b2dd 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/expected/index.html b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/expected/index.html new file mode 100644 index 000000000..f1c91c207 --- /dev/null +++ b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/expected/index.html @@ -0,0 +1,136 @@ + + + + Document Title - Bootstrap Theme + + + + + + + +
+ + +
+
+
+
+
+
+ + +
+
+ + + + +
+

Document Title

+ +

Lorem Ipsum Dolor.

+ +
+ +
+
+ +
+
+
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/expected/objects.inv.json b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/expected/objects.inv.json new file mode 100644 index 000000000..daf84e22d --- /dev/null +++ b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/expected/objects.inv.json @@ -0,0 +1,67 @@ +{ + "std:doc": { + "index": [ + "Bootstrap Theme", + "1.0", + "index.html", + "Document Title" + ], + "someDir\/anotherPage": [ + "Bootstrap Theme", + "1.0", + "someDir\/anotherPage.html", + "Another Page" + ], + "someDir\/index": [ + "Bootstrap Theme", + "1.0", + "someDir\/index.html", + "Some Directory" + ], + "someDir\/somePage": [ + "Bootstrap Theme", + "1.0", + "someDir\/somePage.html", + "Some Page" + ], + "someDir\/yetAnotherPage": [ + "Bootstrap Theme", + "1.0", + "someDir\/yetAnotherPage.html", + "Yet Another Page" + ] + }, + "std:label": [], + "std:title": { + "document-title": [ + "Bootstrap Theme", + "1.0", + "index.html#document-title", + "Document Title" + ], + "another-page": [ + "Bootstrap Theme", + "1.0", + "someDir\/anotherPage.html#another-page", + "Another Page" + ], + "some-directory": [ + "Bootstrap Theme", + "1.0", + "someDir\/index.html#some-directory", + "Some Directory" + ], + "some-page": [ + "Bootstrap Theme", + "1.0", + "someDir\/somePage.html#some-page", + "Some Page" + ], + "yet-another-page": [ + "Bootstrap Theme", + "1.0", + "someDir\/yetAnotherPage.html#yet-another-page", + "Yet Another Page" + ] + } +} \ No newline at end of file diff --git a/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/expected/someDir/yetAnotherPage.html b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/expected/someDir/yetAnotherPage.html new file mode 100644 index 000000000..e46e6630e --- /dev/null +++ b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/expected/someDir/yetAnotherPage.html @@ -0,0 +1,113 @@ + + + + Yet Another Page - Bootstrap Theme + + + + Title in Menu + + + +
+ + +
+
+
+
+
+
+ + +
+
+ + + + +
+

Yet Another Page

+ +

Lorem Ipsum Dolor.

+ +
+ +
+
+
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/guides.xml b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/guides.xml new file mode 100644 index 000000000..18a56f7cf --- /dev/null +++ b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/guides.xml @@ -0,0 +1,9 @@ + + + + diff --git a/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/include.rst.txt b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/include.rst.txt new file mode 100644 index 000000000..c234e39bb --- /dev/null +++ b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/include.rst.txt @@ -0,0 +1,6 @@ +.. documentblock:: + :identifier: footer + + Generated by `phpDocumentor `__. + +.. role:: custom diff --git a/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/index.rst b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/index.rst new file mode 100644 index 000000000..a8f16ecf5 --- /dev/null +++ b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/index.rst @@ -0,0 +1,18 @@ +.. include:: /include.rst.txt + +:project: + Bootstrap Theme +:version: + 1.0 + +============== +Document Title +============== + +Lorem Ipsum Dolor. + +.. toctree:: + :glob: + :titlesonly: + + */index diff --git a/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/someDir/anotherPage.rst b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/someDir/anotherPage.rst new file mode 100644 index 000000000..5e259c9eb --- /dev/null +++ b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/someDir/anotherPage.rst @@ -0,0 +1,7 @@ +.. include:: /include.rst.txt + +============ +Another Page +============ + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/someDir/index.rst b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/someDir/index.rst new file mode 100644 index 000000000..67c1420cd --- /dev/null +++ b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/someDir/index.rst @@ -0,0 +1,13 @@ +.. include:: /include.rst.txt + +============== +Some Directory +============== + +Lorem Ipsum Dolor. + +.. toctree:: + :glob: + :titlesonly: + + * diff --git a/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/someDir/somePage.rst b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/someDir/somePage.rst new file mode 100644 index 000000000..dfdf1d25d --- /dev/null +++ b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/someDir/somePage.rst @@ -0,0 +1,7 @@ +.. include:: /include.rst.txt + +========= +Some Page +========= + +Lorem Ipsum :custom:`Dolor`. diff --git a/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/someDir/yetAnotherPage.rst b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/someDir/yetAnotherPage.rst new file mode 100644 index 000000000..df7bb789d --- /dev/null +++ b/tests/Integration/tests-full/bootstrap/bootstrap-navigation-title-sub-menu/input/someDir/yetAnotherPage.rst @@ -0,0 +1,9 @@ +:navigation-title: Title in Menu + +.. include:: /include.rst.txt + +================ +Yet Another Page +================ + +Lorem Ipsum Dolor.