Skip to content

[BUGFIX] Ignore orphans in toctrees with globbing #1218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function leaveNode(Node $node, CompilerContextInterface $compilerContext)
$node->getTitle() ?? TitleNode::emptyNode(),
$node->isRoot(),
$additionalData,
$node->isOrphan(),
);
$compilerContext->getProjectNode()->addDocumentEntry($entry);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ protected function handleMenuEntry(MenuNode $currentMenu, MenuEntryNode $entryNo
$globExclude = explode(',', $currentMenu->getOption('globExclude') . '');
$menuEntries = [];
foreach ($documentEntries as $documentEntry) {
if ($documentEntry->isOrphan()) {
continue;
}

if (
!self::matches($documentEntry->getFile(), $entryNode, $currentPath, $globExclude)
) {
Expand Down
6 changes: 6 additions & 0 deletions packages/guides/src/Nodes/DocumentTree/DocumentEntryNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function __construct(
private readonly TitleNode $titleNode,
private readonly bool $isRoot = false,
private array $additionalData = [],
private bool $orphan = false,
) {
}

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

public function isOrphan(): bool
{
return $this->orphan;
}

public function addAdditionalData(string $key, Node $value): void
{
$this->additionalData[$key] = $value;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:orphan:

Do not Include in menu
======================

This is an orphan an must be ignored by glob patterns
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:orphan:

Do not Include in menu
======================

This is an orphan an must be ignored by glob patterns
Loading