Skip to content

Commit bbf30b7

Browse files
authored
Merge pull request #1218 from phpDocumentor/task/orphans
[BUGFIX] Ignore orphans in toctrees with globbing
2 parents 8acca14 + 8240bce commit bbf30b7

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

packages/guides/src/Compiler/NodeTransformers/DocumentEntryRegistrationTransformer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public function leaveNode(Node $node, CompilerContextInterface $compilerContext)
6666
$node->getTitle() ?? TitleNode::emptyNode(),
6767
$node->isRoot(),
6868
$additionalData,
69+
$node->isOrphan(),
6970
);
7071
$compilerContext->getProjectNode()->addDocumentEntry($entry);
7172

packages/guides/src/Compiler/NodeTransformers/MenuNodeTransformers/GlobMenuEntryNodeTransformer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ protected function handleMenuEntry(MenuNode $currentMenu, MenuEntryNode $entryNo
4949
$globExclude = explode(',', $currentMenu->getOption('globExclude') . '');
5050
$menuEntries = [];
5151
foreach ($documentEntries as $documentEntry) {
52+
if ($documentEntry->isOrphan()) {
53+
continue;
54+
}
55+
5256
if (
5357
!self::matches($documentEntry->getFile(), $entryNode, $currentPath, $globExclude)
5458
) {

packages/guides/src/Nodes/DocumentTree/DocumentEntryNode.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function __construct(
3434
private readonly TitleNode $titleNode,
3535
private readonly bool $isRoot = false,
3636
private array $additionalData = [],
37+
private bool $orphan = false,
3738
) {
3839
}
3940

@@ -109,6 +110,11 @@ public function getAdditionalData(string $key): Node|null
109110
return $this->additionalData[$key] ?? null;
110111
}
111112

113+
public function isOrphan(): bool
114+
{
115+
return $this->orphan;
116+
}
117+
112118
public function addAdditionalData(string $key, Node $value): void
113119
{
114120
$this->additionalData[$key] = $value;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
:orphan:
2+
3+
Do not Include in menu
4+
======================
5+
6+
This is an orphan an must be ignored by glob patterns
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
:orphan:
2+
3+
Do not Include in menu
4+
======================
5+
6+
This is an orphan an must be ignored by glob patterns

0 commit comments

Comments
 (0)