Skip to content

Commit 83da754

Browse files
authored
Merge pull request #502 from linawolf/feature-orphan
Orphaned pages do not enforce uniqe title
2 parents 26d3c93 + cb74560 commit 83da754

File tree

7 files changed

+50
-1
lines changed

7 files changed

+50
-1
lines changed

packages/guides-restructured-text/src/RestructuredText/Parser/Productions/FieldList/OrphanFieldListItemRule.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public function applies(FieldListItemNode $fieldListItemNode): bool
2020

2121
public function apply(FieldListItemNode $fieldListItemNode, DocumentParserContext $documentParserContext): MetadataNode
2222
{
23+
$documentParserContext->getDocument()->setOrphan(true);
24+
2325
return new OrphanNode();
2426
}
2527
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function leaveNode(Node $node, CompilerContext $compilerContext): Node|nu
3131
return $node;
3232
}
3333

34-
if ($node->getTitle() === null) {
34+
if ($node->getTitle() === null && !$node->isOrphan()) {
3535
$this->logger->warning('Document has not title', $node->getLoggerInformation());
3636
}
3737

packages/guides/src/Nodes/DocumentNode.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ final class DocumentNode extends CompoundNode
6767
private DocumentEntryNode|null $documentEntry = null;
6868
private SectionEntryNode|null $rootSectionEntry = null;
6969
private bool $isRoot = false;
70+
private bool $orphan = false;
7071

7172
public function __construct(
7273
private readonly string $hash,
@@ -285,4 +286,16 @@ public function withIsRoot(bool $isRoot): DocumentNode
285286

286287
return $node;
287288
}
289+
290+
public function isOrphan(): bool
291+
{
292+
return $this->orphan;
293+
}
294+
295+
public function setOrphan(bool $orphan): DocumentNode
296+
{
297+
$this->orphan = $orphan;
298+
299+
return $this;
300+
}
288301
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Document Title</title>
5+
6+
</head>
7+
<body>
8+
<div class="section" id="document-title">
9+
<h1>Document Title</h1>
10+
11+
<p>Some Document</p>
12+
</div>
13+
14+
</body>
15+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title></title>
5+
6+
7+
</head>
8+
<body>
9+
<p>A page without title that is marked as <code>orphan</code> does not cause warnings.</p>
10+
</body>
11+
</html>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
==============
2+
Document Title
3+
==============
4+
5+
Some Document
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:orphan:
2+
3+
A page without title that is marked as `orphan` does not cause warnings.

0 commit comments

Comments
 (0)