From 6301e3592660c9395270eb0bd390711dc4ce2f92 Mon Sep 17 00:00:00 2001 From: "lina.wolf" Date: Sun, 2 Jul 2023 03:05:40 +0000 Subject: [PATCH 1/4] Register Document Entries --- .../NodeTransformers/DocumentEntryRegistrationTransformer.php | 2 +- .../DocumentEntryRegistrationTransformerTest.php | 4 +++- tests/Integration/tests/contents/input/skip | 1 + tests/Integration/tests/toctree-simple/input/skip | 1 + tests/Integration/tests/toctree-titlesonly/input/skip | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 tests/Integration/tests/contents/input/skip create mode 100644 tests/Integration/tests/toctree-simple/input/skip create mode 100644 tests/Integration/tests/toctree-titlesonly/input/skip diff --git a/packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php b/packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php index 58e1083fb..cc75f0408 100644 --- a/packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php +++ b/packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php @@ -35,7 +35,7 @@ public function leaveNode(Node $node, CompilerContext $compilerContext): Node|nu $this->logger->warning('Document has not title', $node->getLoggerInformation()); } - $entry = new DocumentEntryNode($node->getFilePath(), $node->getTitle() ?? TitleNode::emptyNode()); + $entry = new DocumentEntryNode($node->getFilePath(), $node->getTitle()??TitleNode::emptyNode()); $compilerContext->getProjectNode()->addDocumentEntry($entry); return $node->setDocumentEntry($entry); diff --git a/packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php b/packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php index 43330a482..83600faea 100644 --- a/packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php +++ b/packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php @@ -1,15 +1,17 @@ Date: Mon, 3 Jul 2023 05:39:39 +0000 Subject: [PATCH 2/4] Move Menu Entry Creation to TocNodeWithDocumentEntryTransformer --- .../DocumentEntryRegistrationTransformer.php | 2 +- packages/guides/src/Nodes/DocumentNode.php | 2 +- ...cumentEntryRegistrationTransformerTest.php | 5 +- .../MenuNodeTransformerTest.php | 182 ++++++++++++++++++ .../tests/toctree-simple/input/skip | 2 +- .../tests/toctree-titlesonly/input/skip | 1 - 6 files changed, 187 insertions(+), 7 deletions(-) create mode 100644 packages/guides/tests/unit/Compiler/NodeTransformers/MenuNodeTransformerTest.php delete mode 100644 tests/Integration/tests/toctree-titlesonly/input/skip diff --git a/packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php b/packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php index cc75f0408..58e1083fb 100644 --- a/packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php +++ b/packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php @@ -35,7 +35,7 @@ public function leaveNode(Node $node, CompilerContext $compilerContext): Node|nu $this->logger->warning('Document has not title', $node->getLoggerInformation()); } - $entry = new DocumentEntryNode($node->getFilePath(), $node->getTitle()??TitleNode::emptyNode()); + $entry = new DocumentEntryNode($node->getFilePath(), $node->getTitle() ?? TitleNode::emptyNode()); $compilerContext->getProjectNode()->addDocumentEntry($entry); return $node->setDocumentEntry($entry); diff --git a/packages/guides/src/Nodes/DocumentNode.php b/packages/guides/src/Nodes/DocumentNode.php index 86b342b56..5103fe6b4 100644 --- a/packages/guides/src/Nodes/DocumentNode.php +++ b/packages/guides/src/Nodes/DocumentNode.php @@ -246,7 +246,7 @@ public function getFootnoteTargetAnonymous(): FootnoteTarget|null return null; } - public function getDocumentEntry(): DocumentEntryNode + public function getDocumentEntry(): DocumentEntryNode|null { if ($this->documentEntry === null) { throw new Exception('DocumentEntry may not be accessed before initialization'); diff --git a/packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php b/packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php index 83600faea..a71847c26 100644 --- a/packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php +++ b/packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php @@ -1,17 +1,16 @@ withShadowTree(new DocumentNode('123', $path)); + } + + public function testSimpleFlatToc(): void + { + $node = (new TocNode(['index', 'page2']))->withOptions(['maxdepth' => 1]); + $transformer = new MenuNodeTransformer(); + + $transformedNode = $transformer->enterNode($node, self::getCompilerContext('some/path')); + + self::assertEquals( + [ + new TocEntry( + 'index', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1'), 1, 'title-1'), + ), + new TocEntry( + 'page2', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 2'), 1, 'title-2'), + ), + ], + $transformedNode->getMenuEntries(), + ); + } + + public function testTocEntryIsActive(): void + { + $node = (new TocNode(['index', 'page2']))->withOptions(['maxdepth' => 1]); + $transformer = new MenuNodeTransformer(); + + $transformedNode = $transformer->enterNode($node, self::getCompilerContext('index')); + + self::assertEquals( + [ + (new TocEntry( + 'index', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1'), 1, 'title-1'), + ))->withOptions(['active' => 'true']), + new TocEntry( + 'page2', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 2'), 1, 'title-2'), + ), + ], + $transformedNode->getMenuEntries(), + ); + } + + public function testSimpleContents(): void + { + $node = (new ContentMenuNode(['index']))->withOptions(['depth' => 1]); + $transformer = new MenuNodeTransformer(); + + $transformedNode = $transformer->enterNode($node, self::getCompilerContext('some/path')); + + self::assertEquals( + [ + new TocEntry( + 'index', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1'), 1, 'title-1'), + ), + ], + $transformedNode->getMenuEntries(), + ); + } + + public function testTocWithChildNodes(): void + { + $node = (new TocNode(['index', 'page2']))->withOptions(['maxdepth' => 2]); + $transformer = new MenuNodeTransformer(); + + $transformedNode = $transformer->enterNode($node, self::getCompilerContext('some/path')); + + $entry = new TocEntry( + 'index', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1'), 1, 'title-1'), + [ + new TocEntry( + 'index', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1.1'), 2, 'title-1-1'), + ), + new TocEntry( + 'index', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1.2'), 2, 'title-1-2'), + ), + ], + ); + + self::assertEquals( + [ + $entry, + new TocEntry( + 'page2', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 2'), 1, 'title-2'), + ), + ], + $transformedNode->getMenuEntries(), + ); + } + + public function testTocWithDocumentReferences(): void + { + $node = (new TocNode(['page3']))->withOptions(['maxdepth' => 3]); + $transformer = new MenuNodeTransformer(); + + $transformedNode = $transformer->enterNode($node, self::getCompilerContext('some/path')); + + $entry = new TocEntry( + 'index', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1'), 1, 'title-1'), + [ + new TocEntry( + 'index', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1.1'), 2, 'title-1-1'), + ), + new TocEntry( + 'index', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1.2'), 2, 'title-1-2'), + ), + ], + ); + + self::assertEquals( + [ + new TocEntry( + 'page3', + new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 3'), 1, 'title-3'), + ), + $entry, + ], + $transformedNode->getMenuEntries(), + ); + } + + private static function givenProjectNode(): ProjectNode + { + $indexDoc = new DocumentEntryNode('index', TitleNode::emptyNode()); + $section = new SectionEntryNode(new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1'), 1, 'title-1')); + $subSection = new SectionEntryNode(new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1.1'), 2, 'title-1-1')); + $section->addChild($subSection); + $section->addChild(new SectionEntryNode(new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1.2'), 2, 'title-1-2'))); + $indexDoc->addChild($section); + + $page2 = new DocumentEntryNode('page2', TitleNode::emptyNode()); + $page2->addChild(new SectionEntryNode(new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 2'), 1, 'title-2'))); + + $page3 = new DocumentEntryNode('page3', TitleNode::emptyNode()); + $page3->addChild(new SectionEntryNode(new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 3'), 1, 'title-3'))); + $page3->addChild(new DocumentReferenceEntry('index')); + + $projectNode = new ProjectNode(); + $projectNode->setDocumentEntries([ + 'index' => $indexDoc, + 'page2' => $page2, + 'page3' => $page3, + ]); + + return $projectNode; + } +} diff --git a/tests/Integration/tests/toctree-simple/input/skip b/tests/Integration/tests/toctree-simple/input/skip index 6f669060e..fbad1d884 100644 --- a/tests/Integration/tests/toctree-simple/input/skip +++ b/tests/Integration/tests/toctree-simple/input/skip @@ -1 +1 @@ -toctrees do not work currently +toctrees only support (and imply) :titlesonly: currently diff --git a/tests/Integration/tests/toctree-titlesonly/input/skip b/tests/Integration/tests/toctree-titlesonly/input/skip deleted file mode 100644 index 6f669060e..000000000 --- a/tests/Integration/tests/toctree-titlesonly/input/skip +++ /dev/null @@ -1 +0,0 @@ -toctrees do not work currently From ec73789480b346bfa00aa8d48a63b51a32048eac Mon Sep 17 00:00:00 2001 From: "lina.wolf" Date: Tue, 4 Jul 2023 13:33:38 +0000 Subject: [PATCH 3/4] Introduce Transformer for Content Menus This reintroduces the contents directive which was destroyed by switching to transformers --- .../ContentMenuNodeWithSectionEntryTransformer.php | 1 + packages/guides/src/Nodes/DocumentNode.php | 2 +- tests/Integration/tests/contents/input/skip | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 tests/Integration/tests/contents/input/skip diff --git a/packages/guides/src/Compiler/NodeTransformers/ContentMenuNodeWithSectionEntryTransformer.php b/packages/guides/src/Compiler/NodeTransformers/ContentMenuNodeWithSectionEntryTransformer.php index 20d20c48d..b85125de1 100644 --- a/packages/guides/src/Compiler/NodeTransformers/ContentMenuNodeWithSectionEntryTransformer.php +++ b/packages/guides/src/Compiler/NodeTransformers/ContentMenuNodeWithSectionEntryTransformer.php @@ -14,6 +14,7 @@ use phpDocumentor\Guides\Nodes\Node; use function assert; +use function count; use const PHP_INT_MAX; diff --git a/packages/guides/src/Nodes/DocumentNode.php b/packages/guides/src/Nodes/DocumentNode.php index 5103fe6b4..86b342b56 100644 --- a/packages/guides/src/Nodes/DocumentNode.php +++ b/packages/guides/src/Nodes/DocumentNode.php @@ -246,7 +246,7 @@ public function getFootnoteTargetAnonymous(): FootnoteTarget|null return null; } - public function getDocumentEntry(): DocumentEntryNode|null + public function getDocumentEntry(): DocumentEntryNode { if ($this->documentEntry === null) { throw new Exception('DocumentEntry may not be accessed before initialization'); diff --git a/tests/Integration/tests/contents/input/skip b/tests/Integration/tests/contents/input/skip deleted file mode 100644 index 3490b6112..000000000 --- a/tests/Integration/tests/contents/input/skip +++ /dev/null @@ -1 +0,0 @@ -content trees do not work currently From 30f94f003aa9132f2ebede75b1be383b2d85ea7b Mon Sep 17 00:00:00 2001 From: "lina.wolf" Date: Wed, 5 Jul 2023 16:55:16 +0000 Subject: [PATCH 4/4] Enable Multi level Menus To avoid circular relations we need to mark the root document. --- .../body/menu/mainmenu/menu-level.html.twig | 4 +- .../body/menu/navbar/menu-level.html.twig | 4 +- ...entMenuNodeWithSectionEntryTransformer.php | 8 +- .../DocumentEntryRegistrationTransformer.php | 2 +- .../TocNodeSubLevelTransformer.php | 76 ++++++++ .../TocNodeWithDocumentEntryTransformer.php | 76 ++++++-- .../src/Handlers/ParseDirectoryHandler.php | 21 +- .../guides/src/Handlers/ParseFileCommand.php | 6 + .../guides/src/Handlers/ParseFileHandler.php | 4 +- packages/guides/src/Nodes/DocumentNode.php | 14 ++ .../Nodes/DocumentTree/DocumentEntryNode.php | 12 +- .../guides/src/Nodes/Menu/MenuEntryNode.php | 7 +- packages/guides/src/Nodes/ProjectNode.php | 12 ++ ...cumentEntryRegistrationTransformerTest.php | 1 - .../MenuNodeTransformerTest.php | 182 ------------------ ...ocNodeWithDocumentEntryTransformerTest.php | 11 +- .../tests-bootstrap/index/expected/index.html | 9 +- .../index/expected/somePage.html | 23 ++- .../index/input/include.rst.txt | 8 +- .../tests/toctree-level-2/expected/index.html | 38 ++++ .../expected/subfolder/index.html | 13 +- .../expected/subfolder2/index.html | 17 ++ .../tests/toctree-level-2/input/index.rst | 13 ++ .../input/page1.rst | 0 .../input/page2.rst | 0 .../input/subfolder/index.rst | 8 +- .../input/subfolder/subpage1.rst | 0 .../input/subfolder/subpage2.rst | 0 .../input/subfolder2/index.html | 17 ++ .../input/subfolder2/index.rst | 13 ++ .../input/subfolder2/subpage1.rst | 0 .../input/subfolder2/subpage2.rst | 0 .../expected/index.html | 28 +++ .../input/index.rst | 13 ++ .../input/level-1-1/index.rst | 17 ++ .../input/level-1-1/level-2-1/index.rst | 11 ++ .../input/level-1-1/level-2-1/subpage1.rst | 5 + .../input/level-1-1/level-2-1/subpage2.rst | 5 + .../input/level-1-1/level-2-2/index.rst | 11 ++ .../input/level-1-1/level-2-2/subpage1.rst | 5 + .../input/level-1-1/level-2-2/subpage2.rst | 5 + .../input/level-1-1/subpage1.rst | 5 + .../input/level-1-1/subpage2.rst | 5 + .../input/level-1-2/index.rst | 13 ++ .../input/level-1-2/subpage1.rst | 5 + .../input/level-1-2/subpage2.rst | 5 + .../input/page1.rst | 14 ++ .../input/page2.rst | 14 ++ .../expected/index.html | 42 ++++ .../input/index.rst | 13 ++ .../input/level-1-1/index.rst | 17 ++ .../input/level-1-1/level-2-1/index.rst | 11 ++ .../input/level-1-1/level-2-1/subpage1.rst | 5 + .../input/level-1-1/level-2-1/subpage2.rst | 5 + .../input/level-1-1/level-2-2/index.rst | 11 ++ .../input/level-1-1/level-2-2/subpage1.rst | 5 + .../input/level-1-1/level-2-2/subpage2.rst | 5 + .../input/level-1-1/subpage1.rst | 5 + .../input/level-1-1/subpage2.rst | 5 + .../input/level-1-2/index.rst | 13 ++ .../input/level-1-2/subpage1.rst | 5 + .../input/level-1-2/subpage2.rst | 5 + .../input/page1.rst | 14 ++ .../input/page2.rst | 14 ++ .../tests/toctree-level-3/expected/index.html | 52 +++++ .../tests/toctree-level-3/input/index.rst | 12 ++ .../toctree-level-3/input/level-1-1/index.rst | 16 ++ .../input/level-1-1/level-2-1/index.rst | 11 ++ .../input/level-1-1/level-2-1/subpage1.rst | 5 + .../input/level-1-1/level-2-1/subpage2.rst | 5 + .../input/level-1-1/level-2-2/index.rst | 11 ++ .../input/level-1-1/level-2-2/subpage1.rst | 5 + .../input/level-1-1/level-2-2/subpage2.rst | 5 + .../input/level-1-1/subpage1.rst | 5 + .../input/level-1-1/subpage2.rst | 5 + .../toctree-level-3/input/level-1-2/index.rst | 12 ++ .../input/level-1-2/subpage1.rst | 5 + .../input/level-1-2/subpage2.rst | 5 + .../tests/toctree-level-3/input/page1.rst | 14 ++ .../tests/toctree-level-3/input/page2.rst | 14 ++ .../tests/toctree-simple/input/skip | 1 - .../tests/toctree/expected/index.html | 45 ----- .../toctree/expected/subfolder2/index.html | 19 -- .../Integration/tests/toctree/input/index.rst | 11 -- tests/Integration/tests/toctree/input/skip | 1 - .../tests/toctree/input/subfolder2/index.rst | 9 - 86 files changed, 868 insertions(+), 335 deletions(-) create mode 100644 packages/guides/src/Compiler/NodeTransformers/TocNodeSubLevelTransformer.php delete mode 100644 packages/guides/tests/unit/Compiler/NodeTransformers/MenuNodeTransformerTest.php create mode 100644 tests/Integration/tests/toctree-level-2/expected/index.html rename tests/Integration/tests/{toctree => toctree-level-2}/expected/subfolder/index.html (51%) create mode 100644 tests/Integration/tests/toctree-level-2/expected/subfolder2/index.html create mode 100644 tests/Integration/tests/toctree-level-2/input/index.rst rename tests/Integration/tests/{toctree => toctree-level-2}/input/page1.rst (100%) rename tests/Integration/tests/{toctree => toctree-level-2}/input/page2.rst (100%) rename tests/Integration/tests/{toctree => toctree-level-2}/input/subfolder/index.rst (68%) rename tests/Integration/tests/{toctree => toctree-level-2}/input/subfolder/subpage1.rst (100%) rename tests/Integration/tests/{toctree => toctree-level-2}/input/subfolder/subpage2.rst (100%) create mode 100644 tests/Integration/tests/toctree-level-2/input/subfolder2/index.html create mode 100644 tests/Integration/tests/toctree-level-2/input/subfolder2/index.rst rename tests/Integration/tests/{toctree => toctree-level-2}/input/subfolder2/subpage1.rst (100%) rename tests/Integration/tests/{toctree => toctree-level-2}/input/subfolder2/subpage2.rst (100%) create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/expected/index.html create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/index.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/index.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-1/index.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-1/subpage1.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-1/subpage2.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-2/index.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-2/subpage1.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-2/subpage2.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/subpage1.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/subpage2.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-2/index.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-2/subpage1.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-2/subpage2.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/page1.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-1/input/page2.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/expected/index.html create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/index.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/index.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-1/index.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-1/subpage1.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-1/subpage2.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-2/index.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-2/subpage1.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-2/subpage2.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/subpage1.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/subpage2.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-2/index.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-2/subpage1.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-2/subpage2.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/page1.rst create mode 100644 tests/Integration/tests/toctree-level-3-maxdepth-2/input/page2.rst create mode 100644 tests/Integration/tests/toctree-level-3/expected/index.html create mode 100644 tests/Integration/tests/toctree-level-3/input/index.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/level-1-1/index.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-1/index.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-1/subpage1.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-1/subpage2.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-2/index.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-2/subpage1.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-2/subpage2.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/level-1-1/subpage1.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/level-1-1/subpage2.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/level-1-2/index.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/level-1-2/subpage1.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/level-1-2/subpage2.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/page1.rst create mode 100644 tests/Integration/tests/toctree-level-3/input/page2.rst delete mode 100644 tests/Integration/tests/toctree-simple/input/skip delete mode 100644 tests/Integration/tests/toctree/expected/index.html delete mode 100644 tests/Integration/tests/toctree/expected/subfolder2/index.html delete mode 100644 tests/Integration/tests/toctree/input/index.rst delete mode 100644 tests/Integration/tests/toctree/input/skip delete mode 100644 tests/Integration/tests/toctree/input/subfolder2/index.rst diff --git a/packages/guides-theme-bootstrap/resources/template/body/menu/mainmenu/menu-level.html.twig b/packages/guides-theme-bootstrap/resources/template/body/menu/mainmenu/menu-level.html.twig index 94fa7b126..0a2daac84 100644 --- a/packages/guides-theme-bootstrap/resources/template/body/menu/mainmenu/menu-level.html.twig +++ b/packages/guides-theme-bootstrap/resources/template/body/menu/mainmenu/menu-level.html.twig @@ -1,11 +1,11 @@
{% for entry in node.menuEntries -%} - {% spaceless %} + {% apply spaceless %} {{ renderNode(entry.value.value) }} - {% endspaceless %} + {% endapply %} {% endfor %}
diff --git a/packages/guides-theme-bootstrap/resources/template/body/menu/navbar/menu-level.html.twig b/packages/guides-theme-bootstrap/resources/template/body/menu/navbar/menu-level.html.twig index f1a7dab5d..518fa7a61 100644 --- a/packages/guides-theme-bootstrap/resources/template/body/menu/navbar/menu-level.html.twig +++ b/packages/guides-theme-bootstrap/resources/template/body/menu/navbar/menu-level.html.twig @@ -1,6 +1,6 @@ diff --git a/packages/guides/src/Compiler/NodeTransformers/ContentMenuNodeWithSectionEntryTransformer.php b/packages/guides/src/Compiler/NodeTransformers/ContentMenuNodeWithSectionEntryTransformer.php index b85125de1..1daa1cae0 100644 --- a/packages/guides/src/Compiler/NodeTransformers/ContentMenuNodeWithSectionEntryTransformer.php +++ b/packages/guides/src/Compiler/NodeTransformers/ContentMenuNodeWithSectionEntryTransformer.php @@ -14,13 +14,13 @@ use phpDocumentor\Guides\Nodes\Node; use function assert; -use function count; - -use const PHP_INT_MAX; /** @implements NodeTransformer */ class ContentMenuNodeWithSectionEntryTransformer implements NodeTransformer { + // Setting a default level prevents PHP errors in case of circular references + private const DEFAULT_MAX_LEVELS = 10; + public function enterNode(Node $node, CompilerContext $compilerContext): Node { return $node; @@ -32,7 +32,7 @@ public function leaveNode(Node $node, CompilerContext $compilerContext): Node|nu return $node; } - $depth = (int) $node->getOption('depth', PHP_INT_MAX); + $depth = (int) $node->getOption('depth', self::DEFAULT_MAX_LEVELS); $documentEntry = $compilerContext->getDocumentNode()->getDocumentEntry(); $menuEntries = []; diff --git a/packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php b/packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php index 58e1083fb..325cdbdbe 100644 --- a/packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php +++ b/packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php @@ -35,7 +35,7 @@ public function leaveNode(Node $node, CompilerContext $compilerContext): Node|nu $this->logger->warning('Document has not title', $node->getLoggerInformation()); } - $entry = new DocumentEntryNode($node->getFilePath(), $node->getTitle() ?? TitleNode::emptyNode()); + $entry = new DocumentEntryNode($node->getFilePath(), $node->getTitle() ?? TitleNode::emptyNode(), $node->isRoot()); $compilerContext->getProjectNode()->addDocumentEntry($entry); return $node->setDocumentEntry($entry); diff --git a/packages/guides/src/Compiler/NodeTransformers/TocNodeSubLevelTransformer.php b/packages/guides/src/Compiler/NodeTransformers/TocNodeSubLevelTransformer.php new file mode 100644 index 000000000..e919a9dbd --- /dev/null +++ b/packages/guides/src/Compiler/NodeTransformers/TocNodeSubLevelTransformer.php @@ -0,0 +1,76 @@ + */ +class TocNodeSubLevelTransformer implements NodeTransformer +{ + // Setting a default level prevents PHP errors in case of circular references + private const DEFAULT_MAX_LEVELS = 10; + + public function enterNode(Node $node, CompilerContext $compilerContext): Node + { + return $node; + } + + public function leaveNode(Node $node, CompilerContext $compilerContext): Node|null + { + if (!$node instanceof TocNode) { + return $node; + } + + $maxDepth = (int) $node->getOption('maxdepth', self::DEFAULT_MAX_LEVELS); + + + foreach ($node->getMenuEntries() as $menuEntry) { + $documentEntryOfMenuEntry = $compilerContext->getProjectNode()->getDocumentEntry($menuEntry->getUrl()); + $this->addSubEntries($menuEntry, $documentEntryOfMenuEntry, $menuEntry->getLevel() + 1, $maxDepth); + } + + return $node; + } + + private function addSubEntries( + MenuEntryNode $sectionMenuEntry, + DocumentEntryNode $documentEntry, + int $currentLevel, + int $maxDepth, + ): void { + if ($maxDepth < $currentLevel) { + return; + } + + foreach ($documentEntry->getChildren() as $subDocumentEntryNode) { + $subMenuEntry = new MenuEntryNode( + $subDocumentEntryNode->getFile(), + $subDocumentEntryNode->getTitle(), + [], + false, + $currentLevel, + ); + $sectionMenuEntry->addMenuEntry($subMenuEntry); + $this->addSubEntries($subMenuEntry, $subDocumentEntryNode, $currentLevel + 1, $maxDepth); + } + } + + public function supports(Node $node): bool + { + return $node instanceof TocNode; + } + + public function getPriority(): int + { + // After TocNodeWithDocumentEntryTransformer + return 4000; + } +} diff --git a/packages/guides/src/Compiler/NodeTransformers/TocNodeWithDocumentEntryTransformer.php b/packages/guides/src/Compiler/NodeTransformers/TocNodeWithDocumentEntryTransformer.php index 628a90816..466e27707 100644 --- a/packages/guides/src/Compiler/NodeTransformers/TocNodeWithDocumentEntryTransformer.php +++ b/packages/guides/src/Compiler/NodeTransformers/TocNodeWithDocumentEntryTransformer.php @@ -12,18 +12,25 @@ use phpDocumentor\Guides\Nodes\Menu\MenuNode; use phpDocumentor\Guides\Nodes\Menu\TocNode; use phpDocumentor\Guides\Nodes\Node; +use Psr\Log\LoggerInterface; use function array_pop; use function assert; use function explode; use function implode; use function preg_match; +use function sprintf; use function str_replace; use function str_starts_with; /** @implements NodeTransformer */ class TocNodeWithDocumentEntryTransformer implements NodeTransformer { + public function __construct( + private readonly LoggerInterface $logger, + ) { + } + public function enterNode(Node $node, CompilerContext $compilerContext): Node { return $node; @@ -45,7 +52,10 @@ public function leaveNode(Node $node, CompilerContext $compilerContext): Node|nu foreach ($files as $file) { foreach ($documentEntries as $documentEntry) { - if (!$this->isEqualAbsolutePath($documentEntry, $file, $currentPath, $glob) && !$this->isEqualRelativePath($documentEntry, $file, $currentPath, $glob)) { + if ( + !self::isEqualAbsolutePath($documentEntry->getFile(), $file, $currentPath, $glob) + && !self::isEqualRelativePath($documentEntry->getFile(), $file, $currentPath, $glob) + ) { continue; } @@ -64,6 +74,29 @@ public function leaveNode(Node $node, CompilerContext $compilerContext): Node|nu } } + foreach ($documentEntriesInTree as $documentEntryInToc) { + if ($documentEntryInToc->isRoot()) { + // The root page may not be attached to any other + continue; + } + + if ($documentEntryInToc->getParent() !== null && $documentEntryInToc->getParent() !== $compilerContext->getDocumentNode()->getDocumentEntry()) { + $this->logger->warning(sprintf( + 'Document %s has been added to parents %s and %s', + $documentEntryInToc->getFile(), + $documentEntryInToc->getParent()->getFile(), + $compilerContext->getDocumentNode()->getDocumentEntry()->getFile(), + )); + } + + if ($documentEntryInToc->getParent() !== null) { + continue; + } + + $documentEntryInToc->setParent($compilerContext->getDocumentNode()->getDocumentEntry()); + $compilerContext->getDocumentNode()->getDocumentEntry()->addChild($documentEntryInToc); + } + $menuEntries[] = $menuEntry; if (!$glob) { // If glob is not set, there may only be one result per listed file @@ -96,37 +129,41 @@ public function getPriority(): int return 4500; } - private function isEqualAbsolutePath(DocumentEntryNode $documentEntry, string $file, string $currentPath, bool $glob): bool + private static function isEqualAbsolutePath(string $actualFile, string $expectedFile, string $currentFile, bool $glob): bool { - if ($file === '/' . $documentEntry->getFile()) { + if (!self::isAbsoluteFile($expectedFile)) { + return false; + } + + if ($expectedFile === '/' . $actualFile) { return true; } - return $this->isGlob($glob, $documentEntry->getFile(), $currentPath, $file, '/'); + return self::isGlob($glob, $actualFile, $currentFile, $expectedFile, '/'); } - private function isEqualRelativePath(DocumentEntryNode $documentEntry, string $file, string $currentPath, bool $glob): bool + private static function isEqualRelativePath(string $actualFile, string $expectedFile, string $currentFile, bool $glob): bool { - if (str_starts_with($file, '/')) { + if (self::isAbsoluteFile($expectedFile)) { return false; } - $current = explode('/', $currentPath); + $current = explode('/', $currentFile); array_pop($current); - $current[] = $file; - $absolute = implode('/', $current); + $current[] = $expectedFile; + $absoluteExpectedFile = implode('/', $current); - if ($absolute === $documentEntry->getFile()) { + if ($absoluteExpectedFile === $actualFile) { return true; } - return $this->isGlob($glob, $documentEntry->getFile(), $currentPath, $file, ''); + return self::isGlob($glob, $actualFile, $currentFile, $absoluteExpectedFile, ''); } - private function isGlob(bool $glob, string $documentEntryFile, string $currentPath, string $file, string $prefix): bool + private static function isGlob(bool $glob, string $documentEntryFile, string $currentPath, string $file, string $prefix): bool { if ($glob && $documentEntryFile !== $currentPath) { - $file = str_replace('*', '[a-zA-Z0-9]*', $file); + $file = str_replace('*', '[^\/]*', $file); $pattern = '`^' . $file . '$`'; return preg_match($pattern, $prefix . $documentEntryFile) > 0; @@ -134,4 +171,17 @@ private function isGlob(bool $glob, string $documentEntryFile, string $currentPa return false; } + + public static function isPatternMatchingFile(string $absoluteExpectedFile, string $actualFile): bool + { + $pattern = str_replace('*', '[a-zA-Z0-9-_]*', $absoluteExpectedFile); + $pattern = '`^' . $pattern . '$`'; + + return preg_match($pattern, $actualFile) > 0; + } + + public static function isAbsoluteFile(string $expectedFile): bool + { + return str_starts_with($expectedFile, '/'); + } } diff --git a/packages/guides/src/Handlers/ParseDirectoryHandler.php b/packages/guides/src/Handlers/ParseDirectoryHandler.php index bcad44700..281b1a94a 100644 --- a/packages/guides/src/Handlers/ParseDirectoryHandler.php +++ b/packages/guides/src/Handlers/ParseDirectoryHandler.php @@ -29,7 +29,7 @@ public function handle(ParseDirectoryCommand $command): array $currentDirectory = $command->getDirectory(); $extension = $command->getInputFormat(); - $this->guardThatAnIndexFileExists( + $indexName = $this->getDirectoryIndexFile( $origin, $currentDirectory, $extension, @@ -39,34 +39,31 @@ public function handle(ParseDirectoryCommand $command): array $documents = []; foreach ($files as $file) { $documents[] = $this->commandBus->handle( - new ParseFileCommand($origin, $currentDirectory, $file, $extension, 1, $command->getProjectNode()), + new ParseFileCommand($origin, $currentDirectory, $file, $extension, 1, $command->getProjectNode(), $indexName === $file), ); } return $documents; } - private function guardThatAnIndexFileExists( + private function getDirectoryIndexFile( FilesystemInterface $filesystem, string $directory, string $sourceFormat, - ): void { + ): string { $extension = $sourceFormat; $hasIndexFile = false; foreach (self::INDEX_FILE_NAMES as $indexName) { $indexFilename = sprintf('%s.%s', $indexName, $extension); if ($filesystem->has($directory . '/' . $indexFilename)) { - $hasIndexFile = true; - break; + return $indexName; } } - if (!$hasIndexFile) { - $indexFilename = sprintf('%s.%s', self::INDEX_FILE_NAMES[0], $extension); + $indexFilename = sprintf('%s.%s', self::INDEX_FILE_NAMES[0], $extension); - throw new InvalidArgumentException( - sprintf('Could not find index file "%s" in "%s"', $indexFilename, $directory), - ); - } + throw new InvalidArgumentException( + sprintf('Could not find index file "%s" in "%s"', $indexFilename, $directory), + ); } } diff --git a/packages/guides/src/Handlers/ParseFileCommand.php b/packages/guides/src/Handlers/ParseFileCommand.php index 7b9c02a46..fd406ccbf 100644 --- a/packages/guides/src/Handlers/ParseFileCommand.php +++ b/packages/guides/src/Handlers/ParseFileCommand.php @@ -25,6 +25,7 @@ public function __construct( private readonly string $extension, private readonly int $initialHeaderLevel, private readonly ProjectNode $projectNode, + private readonly bool $isRoot, ) { } @@ -57,4 +58,9 @@ public function getProjectNode(): ProjectNode { return $this->projectNode; } + + public function isRoot(): bool + { + return $this->isRoot; + } } diff --git a/packages/guides/src/Handlers/ParseFileHandler.php b/packages/guides/src/Handlers/ParseFileHandler.php index 79d574410..f02c781f6 100644 --- a/packages/guides/src/Handlers/ParseFileHandler.php +++ b/packages/guides/src/Handlers/ParseFileHandler.php @@ -49,6 +49,7 @@ public function handle(ParseFileCommand $command): DocumentNode|null $command->getExtension(), $command->getInitialHeaderLevel(), $command->getProjectNode(), + $command->isRoot(), ); } @@ -74,6 +75,7 @@ private function createDocument( string $extension, int $initialHeaderLevel, ProjectNode $projectNode, + bool $isRoot, ): DocumentNode|null { $path = $this->buildPathOnFileSystem($fileName, $documentFolder, $extension); $fileContents = $this->getFileContents($origin, $path); @@ -93,7 +95,7 @@ private function createDocument( $document = null; try { - $document = $this->parser->parse($preParseDocumentEvent->getContents(), $extension); + $document = $this->parser->parse($preParseDocumentEvent->getContents(), $extension)->withIsRoot($isRoot); } catch (RuntimeException) { $this->logger->error( sprintf('Unable to parse %s, input format was not recognized', $path), diff --git a/packages/guides/src/Nodes/DocumentNode.php b/packages/guides/src/Nodes/DocumentNode.php index 86b342b56..48090b4d1 100644 --- a/packages/guides/src/Nodes/DocumentNode.php +++ b/packages/guides/src/Nodes/DocumentNode.php @@ -66,6 +66,7 @@ final class DocumentNode extends CompoundNode private string|null $metaTitle = null; private DocumentEntryNode|null $documentEntry = null; private SectionEntryNode|null $rootSectionEntry = null; + private bool $isRoot = false; public function __construct( private readonly string $hash, @@ -271,4 +272,17 @@ public function setRootSectionEntry(SectionEntryNode|null $rootSectionEntry): vo { $this->rootSectionEntry = $rootSectionEntry; } + + public function isRoot(): bool + { + return $this->isRoot; + } + + public function withIsRoot(bool $isRoot): DocumentNode + { + $node = clone$this; + $node->isRoot = $isRoot; + + return $node; + } } diff --git a/packages/guides/src/Nodes/DocumentTree/DocumentEntryNode.php b/packages/guides/src/Nodes/DocumentTree/DocumentEntryNode.php index cdc777df4..b9ff1c1f2 100644 --- a/packages/guides/src/Nodes/DocumentTree/DocumentEntryNode.php +++ b/packages/guides/src/Nodes/DocumentTree/DocumentEntryNode.php @@ -17,8 +17,11 @@ final class DocumentEntryNode extends AbstractNode private array $sections = []; private DocumentEntryNode|null $parent = null; - public function __construct(private readonly string $file, private readonly TitleNode $titleNode) - { + public function __construct( + private readonly string $file, + private readonly TitleNode $titleNode, + private readonly bool $isRoot = false, + ) { } public function getTitle(): TitleNode @@ -62,4 +65,9 @@ public function getFile(): string { return $this->file; } + + public function isRoot(): bool + { + return $this->isRoot; + } } diff --git a/packages/guides/src/Nodes/Menu/MenuEntryNode.php b/packages/guides/src/Nodes/Menu/MenuEntryNode.php index d5c0ef187..85916aaaa 100644 --- a/packages/guides/src/Nodes/Menu/MenuEntryNode.php +++ b/packages/guides/src/Nodes/Menu/MenuEntryNode.php @@ -17,7 +17,7 @@ final class MenuEntryNode extends AbstractNode public function __construct( private readonly string $url, TitleNode $title, - private readonly array $children = [], + private array $children = [], private readonly bool $isDocumentRoot = false, private readonly int $level = 1, private readonly string $anchor = '', @@ -47,6 +47,11 @@ public function getEntries(): array return $this->children; } + public function addMenuEntry(MenuEntryNode $menuEntryNode): void + { + $this->children[] = $menuEntryNode; + } + public function isDocumentRoot(): bool { return $this->isDocumentRoot; diff --git a/packages/guides/src/Nodes/ProjectNode.php b/packages/guides/src/Nodes/ProjectNode.php index 16dd944c3..efe777350 100644 --- a/packages/guides/src/Nodes/ProjectNode.php +++ b/packages/guides/src/Nodes/ProjectNode.php @@ -4,6 +4,7 @@ namespace phpDocumentor\Guides\Nodes; +use Exception; use phpDocumentor\Guides\Meta\CitationTarget; use phpDocumentor\Guides\Meta\InternalTarget; use phpDocumentor\Guides\Nodes\DocumentTree\DocumentEntryNode; @@ -114,6 +115,17 @@ public function getAllDocumentEntries(): array return $this->documentEntries; } + public function getDocumentEntry(string $file): DocumentEntryNode + { + foreach ($this->documentEntries as $documentEntry) { + if ($documentEntry->getFile() === $file) { + return $documentEntry; + } + } + + throw new Exception('No document Entry found for file ' . $file); + } + /** @param DocumentEntryNode[] $documentEntries */ public function setDocumentEntries(array $documentEntries): void { diff --git a/packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php b/packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php index a71847c26..43330a482 100644 --- a/packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php +++ b/packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php @@ -1,5 +1,4 @@ withShadowTree(new DocumentNode('123', $path)); - } - - public function testSimpleFlatToc(): void - { - $node = (new TocNode(['index', 'page2']))->withOptions(['maxdepth' => 1]); - $transformer = new MenuNodeTransformer(); - - $transformedNode = $transformer->enterNode($node, self::getCompilerContext('some/path')); - - self::assertEquals( - [ - new TocEntry( - 'index', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1'), 1, 'title-1'), - ), - new TocEntry( - 'page2', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 2'), 1, 'title-2'), - ), - ], - $transformedNode->getMenuEntries(), - ); - } - - public function testTocEntryIsActive(): void - { - $node = (new TocNode(['index', 'page2']))->withOptions(['maxdepth' => 1]); - $transformer = new MenuNodeTransformer(); - - $transformedNode = $transformer->enterNode($node, self::getCompilerContext('index')); - - self::assertEquals( - [ - (new TocEntry( - 'index', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1'), 1, 'title-1'), - ))->withOptions(['active' => 'true']), - new TocEntry( - 'page2', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 2'), 1, 'title-2'), - ), - ], - $transformedNode->getMenuEntries(), - ); - } - - public function testSimpleContents(): void - { - $node = (new ContentMenuNode(['index']))->withOptions(['depth' => 1]); - $transformer = new MenuNodeTransformer(); - - $transformedNode = $transformer->enterNode($node, self::getCompilerContext('some/path')); - - self::assertEquals( - [ - new TocEntry( - 'index', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1'), 1, 'title-1'), - ), - ], - $transformedNode->getMenuEntries(), - ); - } - - public function testTocWithChildNodes(): void - { - $node = (new TocNode(['index', 'page2']))->withOptions(['maxdepth' => 2]); - $transformer = new MenuNodeTransformer(); - - $transformedNode = $transformer->enterNode($node, self::getCompilerContext('some/path')); - - $entry = new TocEntry( - 'index', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1'), 1, 'title-1'), - [ - new TocEntry( - 'index', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1.1'), 2, 'title-1-1'), - ), - new TocEntry( - 'index', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1.2'), 2, 'title-1-2'), - ), - ], - ); - - self::assertEquals( - [ - $entry, - new TocEntry( - 'page2', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 2'), 1, 'title-2'), - ), - ], - $transformedNode->getMenuEntries(), - ); - } - - public function testTocWithDocumentReferences(): void - { - $node = (new TocNode(['page3']))->withOptions(['maxdepth' => 3]); - $transformer = new MenuNodeTransformer(); - - $transformedNode = $transformer->enterNode($node, self::getCompilerContext('some/path')); - - $entry = new TocEntry( - 'index', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1'), 1, 'title-1'), - [ - new TocEntry( - 'index', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1.1'), 2, 'title-1-1'), - ), - new TocEntry( - 'index', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1.2'), 2, 'title-1-2'), - ), - ], - ); - - self::assertEquals( - [ - new TocEntry( - 'page3', - new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 3'), 1, 'title-3'), - ), - $entry, - ], - $transformedNode->getMenuEntries(), - ); - } - - private static function givenProjectNode(): ProjectNode - { - $indexDoc = new DocumentEntryNode('index', TitleNode::emptyNode()); - $section = new SectionEntryNode(new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1'), 1, 'title-1')); - $subSection = new SectionEntryNode(new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1.1'), 2, 'title-1-1')); - $section->addChild($subSection); - $section->addChild(new SectionEntryNode(new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 1.2'), 2, 'title-1-2'))); - $indexDoc->addChild($section); - - $page2 = new DocumentEntryNode('page2', TitleNode::emptyNode()); - $page2->addChild(new SectionEntryNode(new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 2'), 1, 'title-2'))); - - $page3 = new DocumentEntryNode('page3', TitleNode::emptyNode()); - $page3->addChild(new SectionEntryNode(new TitleNode(InlineCompoundNode::getPlainTextInlineNode('Title 3'), 1, 'title-3'))); - $page3->addChild(new DocumentReferenceEntry('index')); - - $projectNode = new ProjectNode(); - $projectNode->setDocumentEntries([ - 'index' => $indexDoc, - 'page2' => $page2, - 'page3' => $page3, - ]); - - return $projectNode; - } -} diff --git a/packages/guides/tests/unit/Compiler/NodeTransformers/TocNodeWithDocumentEntryTransformerTest.php b/packages/guides/tests/unit/Compiler/NodeTransformers/TocNodeWithDocumentEntryTransformerTest.php index ea9c0f5b5..b68b82fa9 100644 --- a/packages/guides/tests/unit/Compiler/NodeTransformers/TocNodeWithDocumentEntryTransformerTest.php +++ b/packages/guides/tests/unit/Compiler/NodeTransformers/TocNodeWithDocumentEntryTransformerTest.php @@ -12,6 +12,7 @@ use phpDocumentor\Guides\Nodes\TitleNode; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; class TocNodeWithDocumentEntryTransformerTest extends TestCase { @@ -27,7 +28,10 @@ private static function getCompilerContext(string $currentPath, array $paths): C $projectNode->setDocumentEntries($documentEntries); $context = new CompilerContext($projectNode); - return $context->withShadowTree(new DocumentNode('123', $currentPath)); + $documentNode = new DocumentNode('123', $currentPath); + $documentNode->setDocumentEntry(new DocumentEntryNode($currentPath, TitleNode::emptyNode())); + + return $context->withShadowTree($documentNode); } /** @@ -44,7 +48,10 @@ public function testTocTreeEntryCount(string $currentPath, array $paths, array $ $node = $node->withOptions(['glob' => true]); } - $transformer = new TocNodeWithDocumentEntryTransformer(); + $mockLogger = $this->createMock(LoggerInterface::class); + $mockLogger->expects($this->never())->method('warning'); + $mockLogger->expects($this->never())->method('error'); + $transformer = new TocNodeWithDocumentEntryTransformer($mockLogger); $result = $transformer->leaveNode($node, $context); self::assertInstanceOf(TocNode::class, $result); diff --git a/tests/Integration/tests-bootstrap/index/expected/index.html b/tests/Integration/tests-bootstrap/index/expected/index.html index 5329d06f0..e137884f5 100644 --- a/tests/Integration/tests-bootstrap/index/expected/index.html +++ b/tests/Integration/tests-bootstrap/index/expected/index.html @@ -23,10 +23,6 @@ + + @@ -48,10 +50,13 @@ Document Title - - Some Page - + +
diff --git a/tests/Integration/tests-bootstrap/index/input/include.rst.txt b/tests/Integration/tests-bootstrap/index/input/include.rst.txt index 8e0bc1113..2fdb3b738 100644 --- a/tests/Integration/tests-bootstrap/index/input/include.rst.txt +++ b/tests/Integration/tests-bootstrap/index/input/include.rst.txt @@ -5,18 +5,18 @@ .. toctree:: :titlesonly: + :glob: - /index - /somePage + * .. documentblock:: :identifier: navbar .. toctree:: :titlesonly: + :glob: - /index - /somePage + * .. documentblock:: :identifier: footer diff --git a/tests/Integration/tests/toctree-level-2/expected/index.html b/tests/Integration/tests/toctree-level-2/expected/index.html new file mode 100644 index 000000000..8942cc818 --- /dev/null +++ b/tests/Integration/tests/toctree-level-2/expected/index.html @@ -0,0 +1,38 @@ + + + + Document Title + + + +
+

Document Title

+ +

Lorem Ipsum Dolor.

+ + +
+ + + diff --git a/tests/Integration/tests/toctree/expected/subfolder/index.html b/tests/Integration/tests/toctree-level-2/expected/subfolder/index.html similarity index 51% rename from tests/Integration/tests/toctree/expected/subfolder/index.html rename to tests/Integration/tests/toctree-level-2/expected/subfolder/index.html index 468f7eb91..a9640de88 100644 --- a/tests/Integration/tests/toctree/expected/subfolder/index.html +++ b/tests/Integration/tests/toctree-level-2/expected/subfolder/index.html @@ -1,7 +1,8 @@ -index + Subfolder Index +
@@ -13,7 +14,15 @@

Subfolder Index

Some definition.
- +
+ +
+
diff --git a/tests/Integration/tests/toctree-level-2/expected/subfolder2/index.html b/tests/Integration/tests/toctree-level-2/expected/subfolder2/index.html new file mode 100644 index 000000000..a5c109a77 --- /dev/null +++ b/tests/Integration/tests/toctree-level-2/expected/subfolder2/index.html @@ -0,0 +1,17 @@ + + + + Subfolder Index + + + +
+

Subfolder Index

+ +

The toctree on this page is hidden. Its subpages are displayed only in +the parent menu.

+ +
+ + + diff --git a/tests/Integration/tests/toctree-level-2/input/index.rst b/tests/Integration/tests/toctree-level-2/input/index.rst new file mode 100644 index 000000000..45d38bfe2 --- /dev/null +++ b/tests/Integration/tests/toctree-level-2/input/index.rst @@ -0,0 +1,13 @@ +============== +Document Title +============== + +Lorem Ipsum Dolor. + + +.. toctree:: + :glob: + :titlesonly: + + * + */index diff --git a/tests/Integration/tests/toctree/input/page1.rst b/tests/Integration/tests/toctree-level-2/input/page1.rst similarity index 100% rename from tests/Integration/tests/toctree/input/page1.rst rename to tests/Integration/tests/toctree-level-2/input/page1.rst diff --git a/tests/Integration/tests/toctree/input/page2.rst b/tests/Integration/tests/toctree-level-2/input/page2.rst similarity index 100% rename from tests/Integration/tests/toctree/input/page2.rst rename to tests/Integration/tests/toctree-level-2/input/page2.rst diff --git a/tests/Integration/tests/toctree/input/subfolder/index.rst b/tests/Integration/tests/toctree-level-2/input/subfolder/index.rst similarity index 68% rename from tests/Integration/tests/toctree/input/subfolder/index.rst rename to tests/Integration/tests/toctree-level-2/input/subfolder/index.rst index bc657fe4b..a49cb73d5 100644 --- a/tests/Integration/tests/toctree/input/subfolder/index.rst +++ b/tests/Integration/tests/toctree-level-2/input/subfolder/index.rst @@ -7,6 +7,8 @@ Lorem Ipsum Dolor. A Definition List Some definition. -.. toctree:: - subpage1 - subpage2 +.. toctree:: + :glob: + :titlesonly: + + * diff --git a/tests/Integration/tests/toctree/input/subfolder/subpage1.rst b/tests/Integration/tests/toctree-level-2/input/subfolder/subpage1.rst similarity index 100% rename from tests/Integration/tests/toctree/input/subfolder/subpage1.rst rename to tests/Integration/tests/toctree-level-2/input/subfolder/subpage1.rst diff --git a/tests/Integration/tests/toctree/input/subfolder/subpage2.rst b/tests/Integration/tests/toctree-level-2/input/subfolder/subpage2.rst similarity index 100% rename from tests/Integration/tests/toctree/input/subfolder/subpage2.rst rename to tests/Integration/tests/toctree-level-2/input/subfolder/subpage2.rst diff --git a/tests/Integration/tests/toctree-level-2/input/subfolder2/index.html b/tests/Integration/tests/toctree-level-2/input/subfolder2/index.html new file mode 100644 index 000000000..a5c109a77 --- /dev/null +++ b/tests/Integration/tests/toctree-level-2/input/subfolder2/index.html @@ -0,0 +1,17 @@ + + + + Subfolder Index + + + +
+

Subfolder Index

+ +

The toctree on this page is hidden. Its subpages are displayed only in +the parent menu.

+ +
+ + + diff --git a/tests/Integration/tests/toctree-level-2/input/subfolder2/index.rst b/tests/Integration/tests/toctree-level-2/input/subfolder2/index.rst new file mode 100644 index 000000000..f80d9aefc --- /dev/null +++ b/tests/Integration/tests/toctree-level-2/input/subfolder2/index.rst @@ -0,0 +1,13 @@ +=============== +Subfolder Index +=============== + +The toctree on this page is hidden. Its subpages are displayed only in +the parent menu. + +.. toctree:: + :glob: + :titlesonly: + :hidden: + + * diff --git a/tests/Integration/tests/toctree/input/subfolder2/subpage1.rst b/tests/Integration/tests/toctree-level-2/input/subfolder2/subpage1.rst similarity index 100% rename from tests/Integration/tests/toctree/input/subfolder2/subpage1.rst rename to tests/Integration/tests/toctree-level-2/input/subfolder2/subpage1.rst diff --git a/tests/Integration/tests/toctree/input/subfolder2/subpage2.rst b/tests/Integration/tests/toctree-level-2/input/subfolder2/subpage2.rst similarity index 100% rename from tests/Integration/tests/toctree/input/subfolder2/subpage2.rst rename to tests/Integration/tests/toctree-level-2/input/subfolder2/subpage2.rst diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/expected/index.html b/tests/Integration/tests/toctree-level-3-maxdepth-1/expected/index.html new file mode 100644 index 000000000..55ba511b2 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/expected/index.html @@ -0,0 +1,28 @@ + + + + Document Title + + + +
+

Document Title

+ +

Lorem Ipsum Dolor.

+
+ +
+ +
+ + + diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/index.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/index.rst new file mode 100644 index 000000000..f8356402e --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/index.rst @@ -0,0 +1,13 @@ +============== +Document Title +============== + +Lorem Ipsum Dolor. + +.. toctree:: + :glob: + :titlesonly: + :maxdepth: 1 + + * + */index diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/index.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/index.rst new file mode 100644 index 000000000..e21cf4d7a --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/index.rst @@ -0,0 +1,17 @@ +========= +Level 1-1 +========= + +Lorem Ipsum Dolor. + +A Definition List + Some definition. + + +.. toctree:: + :glob: + :titlesonly: + :maxdepth: 1 + + * + */index diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-1/index.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-1/index.rst new file mode 100644 index 000000000..31cd7ca24 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-1/index.rst @@ -0,0 +1,11 @@ +========= +Level 2-1 +========= + +A Toctree with multiple whitespaces in the directive: + +.. toctree:: + :glob: + :titlesonly: + + * diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-1/subpage1.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-1/subpage1.rst new file mode 100644 index 000000000..cb49d6baa --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-1/subpage1.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 2-1 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-1/subpage2.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-1/subpage2.rst new file mode 100644 index 000000000..ceea6a3d4 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-1/subpage2.rst @@ -0,0 +1,5 @@ +==================== +Subpage 2, Level 2-1 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-2/index.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-2/index.rst new file mode 100644 index 000000000..e2b7e596e --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-2/index.rst @@ -0,0 +1,11 @@ +========= +Level 2-2 +========= + +A Toctree with multiple whitespaces in the directive: + +.. toctree:: + :glob: + :titlesonly: + + * diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-2/subpage1.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-2/subpage1.rst new file mode 100644 index 000000000..fb4915895 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-2/subpage1.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 2-2 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-2/subpage2.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-2/subpage2.rst new file mode 100644 index 000000000..fb4915895 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/level-2-2/subpage2.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 2-2 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/subpage1.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/subpage1.rst new file mode 100644 index 000000000..ba6aa0052 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/subpage1.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 1-1 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/subpage2.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/subpage2.rst new file mode 100644 index 000000000..06615899a --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-1/subpage2.rst @@ -0,0 +1,5 @@ +==================== +Subpage 2, Level 1-1 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-2/index.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-2/index.rst new file mode 100644 index 000000000..48035aef2 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-2/index.rst @@ -0,0 +1,13 @@ +========= +Level 1-2 +========= + +A Toctree with multiple whitespaces in the directive: + + +.. toctree:: + :glob: + :titlesonly: + :maxdepth: 1 + + * diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-2/subpage1.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-2/subpage1.rst new file mode 100644 index 000000000..0371975a0 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-2/subpage1.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 1-2 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-2/subpage2.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-2/subpage2.rst new file mode 100644 index 000000000..0371975a0 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/level-1-2/subpage2.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 1-2 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/page1.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/page1.rst new file mode 100644 index 000000000..9a1df3ce9 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/page1.rst @@ -0,0 +1,14 @@ +====== +Page 1 +====== + +Lorem Ipsum Dolor. + +Page 1 Level 2 +-------------- + +Page 1 Level 3 +~~~~~~~~~~~~~~ + +Page 1 Level 4 +"""""""""""""" diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-1/input/page2.rst b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/page2.rst new file mode 100644 index 000000000..cdd19d739 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-1/input/page2.rst @@ -0,0 +1,14 @@ +====== +Page 2 +====== + +Lorem Ipsum Dolor. + +Page 2 Level 2 +-------------- + +Page 2 Level 3 +~~~~~~~~~~~~~~ + +Page 2 Level 4 +"""""""""""""" diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/expected/index.html b/tests/Integration/tests/toctree-level-3-maxdepth-2/expected/index.html new file mode 100644 index 000000000..57e17d332 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/expected/index.html @@ -0,0 +1,42 @@ + + + + Document Title + + + +
+

Document Title

+ +

Lorem Ipsum Dolor.

+ + +
+ + + diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/index.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/index.rst new file mode 100644 index 000000000..7d8f9a4ad --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/index.rst @@ -0,0 +1,13 @@ +============== +Document Title +============== + +Lorem Ipsum Dolor. + +.. toctree:: + :glob: + :titlesonly: + :maxdepth: 2 + + * + */index diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/index.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/index.rst new file mode 100644 index 000000000..e21cf4d7a --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/index.rst @@ -0,0 +1,17 @@ +========= +Level 1-1 +========= + +Lorem Ipsum Dolor. + +A Definition List + Some definition. + + +.. toctree:: + :glob: + :titlesonly: + :maxdepth: 1 + + * + */index diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-1/index.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-1/index.rst new file mode 100644 index 000000000..31cd7ca24 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-1/index.rst @@ -0,0 +1,11 @@ +========= +Level 2-1 +========= + +A Toctree with multiple whitespaces in the directive: + +.. toctree:: + :glob: + :titlesonly: + + * diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-1/subpage1.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-1/subpage1.rst new file mode 100644 index 000000000..cb49d6baa --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-1/subpage1.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 2-1 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-1/subpage2.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-1/subpage2.rst new file mode 100644 index 000000000..ceea6a3d4 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-1/subpage2.rst @@ -0,0 +1,5 @@ +==================== +Subpage 2, Level 2-1 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-2/index.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-2/index.rst new file mode 100644 index 000000000..e2b7e596e --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-2/index.rst @@ -0,0 +1,11 @@ +========= +Level 2-2 +========= + +A Toctree with multiple whitespaces in the directive: + +.. toctree:: + :glob: + :titlesonly: + + * diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-2/subpage1.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-2/subpage1.rst new file mode 100644 index 000000000..fb4915895 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-2/subpage1.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 2-2 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-2/subpage2.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-2/subpage2.rst new file mode 100644 index 000000000..fb4915895 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/level-2-2/subpage2.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 2-2 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/subpage1.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/subpage1.rst new file mode 100644 index 000000000..ba6aa0052 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/subpage1.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 1-1 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/subpage2.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/subpage2.rst new file mode 100644 index 000000000..06615899a --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-1/subpage2.rst @@ -0,0 +1,5 @@ +==================== +Subpage 2, Level 1-1 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-2/index.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-2/index.rst new file mode 100644 index 000000000..48035aef2 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-2/index.rst @@ -0,0 +1,13 @@ +========= +Level 1-2 +========= + +A Toctree with multiple whitespaces in the directive: + + +.. toctree:: + :glob: + :titlesonly: + :maxdepth: 1 + + * diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-2/subpage1.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-2/subpage1.rst new file mode 100644 index 000000000..0371975a0 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-2/subpage1.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 1-2 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-2/subpage2.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-2/subpage2.rst new file mode 100644 index 000000000..0371975a0 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/level-1-2/subpage2.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 1-2 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/page1.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/page1.rst new file mode 100644 index 000000000..9a1df3ce9 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/page1.rst @@ -0,0 +1,14 @@ +====== +Page 1 +====== + +Lorem Ipsum Dolor. + +Page 1 Level 2 +-------------- + +Page 1 Level 3 +~~~~~~~~~~~~~~ + +Page 1 Level 4 +"""""""""""""" diff --git a/tests/Integration/tests/toctree-level-3-maxdepth-2/input/page2.rst b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/page2.rst new file mode 100644 index 000000000..cdd19d739 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3-maxdepth-2/input/page2.rst @@ -0,0 +1,14 @@ +====== +Page 2 +====== + +Lorem Ipsum Dolor. + +Page 2 Level 2 +-------------- + +Page 2 Level 3 +~~~~~~~~~~~~~~ + +Page 2 Level 4 +"""""""""""""" diff --git a/tests/Integration/tests/toctree-level-3/expected/index.html b/tests/Integration/tests/toctree-level-3/expected/index.html new file mode 100644 index 000000000..e3bb2f4b6 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/expected/index.html @@ -0,0 +1,52 @@ + + + + Document Title + + + + + + + diff --git a/tests/Integration/tests/toctree-level-3/input/index.rst b/tests/Integration/tests/toctree-level-3/input/index.rst new file mode 100644 index 000000000..bf9abc63d --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/index.rst @@ -0,0 +1,12 @@ +============== +Document Title +============== + +Lorem Ipsum Dolor. + +.. toctree:: + :glob: + :titlesonly: + + * + */index diff --git a/tests/Integration/tests/toctree-level-3/input/level-1-1/index.rst b/tests/Integration/tests/toctree-level-3/input/level-1-1/index.rst new file mode 100644 index 000000000..33745426e --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/level-1-1/index.rst @@ -0,0 +1,16 @@ +========= +Level 1-1 +========= + +Lorem Ipsum Dolor. + +A Definition List + Some definition. + + +.. toctree:: + :glob: + :titlesonly: + + * + */index diff --git a/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-1/index.rst b/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-1/index.rst new file mode 100644 index 000000000..31cd7ca24 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-1/index.rst @@ -0,0 +1,11 @@ +========= +Level 2-1 +========= + +A Toctree with multiple whitespaces in the directive: + +.. toctree:: + :glob: + :titlesonly: + + * diff --git a/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-1/subpage1.rst b/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-1/subpage1.rst new file mode 100644 index 000000000..cb49d6baa --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-1/subpage1.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 2-1 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-1/subpage2.rst b/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-1/subpage2.rst new file mode 100644 index 000000000..ceea6a3d4 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-1/subpage2.rst @@ -0,0 +1,5 @@ +==================== +Subpage 2, Level 2-1 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-2/index.rst b/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-2/index.rst new file mode 100644 index 000000000..e2b7e596e --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-2/index.rst @@ -0,0 +1,11 @@ +========= +Level 2-2 +========= + +A Toctree with multiple whitespaces in the directive: + +.. toctree:: + :glob: + :titlesonly: + + * diff --git a/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-2/subpage1.rst b/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-2/subpage1.rst new file mode 100644 index 000000000..fb4915895 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-2/subpage1.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 2-2 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-2/subpage2.rst b/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-2/subpage2.rst new file mode 100644 index 000000000..fb4915895 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/level-1-1/level-2-2/subpage2.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 2-2 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3/input/level-1-1/subpage1.rst b/tests/Integration/tests/toctree-level-3/input/level-1-1/subpage1.rst new file mode 100644 index 000000000..ba6aa0052 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/level-1-1/subpage1.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 1-1 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3/input/level-1-1/subpage2.rst b/tests/Integration/tests/toctree-level-3/input/level-1-1/subpage2.rst new file mode 100644 index 000000000..06615899a --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/level-1-1/subpage2.rst @@ -0,0 +1,5 @@ +==================== +Subpage 2, Level 1-1 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3/input/level-1-2/index.rst b/tests/Integration/tests/toctree-level-3/input/level-1-2/index.rst new file mode 100644 index 000000000..985719e0b --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/level-1-2/index.rst @@ -0,0 +1,12 @@ +========= +Level 1-2 +========= + +A Toctree with multiple whitespaces in the directive: + + +.. toctree:: + :glob: + :titlesonly: + + * diff --git a/tests/Integration/tests/toctree-level-3/input/level-1-2/subpage1.rst b/tests/Integration/tests/toctree-level-3/input/level-1-2/subpage1.rst new file mode 100644 index 000000000..0371975a0 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/level-1-2/subpage1.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 1-2 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3/input/level-1-2/subpage2.rst b/tests/Integration/tests/toctree-level-3/input/level-1-2/subpage2.rst new file mode 100644 index 000000000..0371975a0 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/level-1-2/subpage2.rst @@ -0,0 +1,5 @@ +==================== +Subpage 1, Level 1-2 +==================== + +Lorem Ipsum Dolor. diff --git a/tests/Integration/tests/toctree-level-3/input/page1.rst b/tests/Integration/tests/toctree-level-3/input/page1.rst new file mode 100644 index 000000000..9a1df3ce9 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/page1.rst @@ -0,0 +1,14 @@ +====== +Page 1 +====== + +Lorem Ipsum Dolor. + +Page 1 Level 2 +-------------- + +Page 1 Level 3 +~~~~~~~~~~~~~~ + +Page 1 Level 4 +"""""""""""""" diff --git a/tests/Integration/tests/toctree-level-3/input/page2.rst b/tests/Integration/tests/toctree-level-3/input/page2.rst new file mode 100644 index 000000000..cdd19d739 --- /dev/null +++ b/tests/Integration/tests/toctree-level-3/input/page2.rst @@ -0,0 +1,14 @@ +====== +Page 2 +====== + +Lorem Ipsum Dolor. + +Page 2 Level 2 +-------------- + +Page 2 Level 3 +~~~~~~~~~~~~~~ + +Page 2 Level 4 +"""""""""""""" diff --git a/tests/Integration/tests/toctree-simple/input/skip b/tests/Integration/tests/toctree-simple/input/skip deleted file mode 100644 index fbad1d884..000000000 --- a/tests/Integration/tests/toctree-simple/input/skip +++ /dev/null @@ -1 +0,0 @@ -toctrees only support (and imply) :titlesonly: currently diff --git a/tests/Integration/tests/toctree/expected/index.html b/tests/Integration/tests/toctree/expected/index.html deleted file mode 100644 index f959e1852..000000000 --- a/tests/Integration/tests/toctree/expected/index.html +++ /dev/null @@ -1,45 +0,0 @@ - - - -index - - -
-

Document Title

- -

Lorem Ipsum Dolor.

- -
- - diff --git a/tests/Integration/tests/toctree/expected/subfolder2/index.html b/tests/Integration/tests/toctree/expected/subfolder2/index.html deleted file mode 100644 index 6366d313f..000000000 --- a/tests/Integration/tests/toctree/expected/subfolder2/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - - -index - - -
-

Subfolder Index

-

A Toctree with multiple whitespaces in the directive:

- -
- -
-
- - diff --git a/tests/Integration/tests/toctree/input/index.rst b/tests/Integration/tests/toctree/input/index.rst deleted file mode 100644 index 40c66da13..000000000 --- a/tests/Integration/tests/toctree/input/index.rst +++ /dev/null @@ -1,11 +0,0 @@ -============== -Document Title -============== - -Lorem Ipsum Dolor. - -.. toctree:: - page1 - page2 - subfolder/index - subfolder2/index diff --git a/tests/Integration/tests/toctree/input/skip b/tests/Integration/tests/toctree/input/skip deleted file mode 100644 index fbad1d884..000000000 --- a/tests/Integration/tests/toctree/input/skip +++ /dev/null @@ -1 +0,0 @@ -toctrees only support (and imply) :titlesonly: currently diff --git a/tests/Integration/tests/toctree/input/subfolder2/index.rst b/tests/Integration/tests/toctree/input/subfolder2/index.rst deleted file mode 100644 index 6e9aae666..000000000 --- a/tests/Integration/tests/toctree/input/subfolder2/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -=============== -Subfolder Index -=============== - -A Toctree with multiple whitespaces in the directive: - -.. toctree:: - subpage1 - subpage2