Skip to content

Commit 5e039bc

Browse files
linawolfjaapio
authored andcommitted
Register Document Entries
1 parent 9564b93 commit 5e039bc

File tree

7 files changed

+13
-7
lines changed

7 files changed

+13
-7
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ public function leaveNode(Node $node, CompilerContext $compilerContext): Node|nu
3535
$this->logger->warning('Document has not title', $node->getLoggerInformation());
3636
}
3737

38-
$entry = new DocumentEntryNode($node->getFilePath(), $node->getTitle() ?? TitleNode::emptyNode());
38+
$entry = new DocumentEntryNode($node->getFilePath(), $node->getTitle()??TitleNode::emptyNode());
3939
$compilerContext->getProjectNode()->addDocumentEntry($entry);
40-
$node->setDocumentEntry($entry);
4140

42-
return $node;
41+
return $node->withDocumentEntry($entry);
4342
}
4443

4544
public function supports(Node $node): bool

packages/guides/src/Nodes/DocumentNode.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,17 +250,19 @@ public function getDocumentEntry(): DocumentEntryNode|null
250250
return $this->documentEntry;
251251
}
252252

253-
public function setDocumentEntry(DocumentEntryNode $documentEntry): void
253+
public function withDocumentEntry(DocumentEntryNode $documentEntry): DocumentNode
254254
{
255-
$this->documentEntry = $documentEntry;
255+
$node = clone($this);
256+
$node->documentEntry = $documentEntry;
257+
return $node;
256258
}
257259

258-
public function getRootSectionEntry(): SectionEntryNode|null
260+
public function getRootSectionEntry(): ?SectionEntryNode
259261
{
260262
return $this->rootSectionEntry;
261263
}
262264

263-
public function setRootSectionEntry(SectionEntryNode|null $rootSectionEntry): void
265+
public function setRootSectionEntry(?SectionEntryNode $rootSectionEntry): void
264266
{
265267
$this->rootSectionEntry = $rootSectionEntry;
266268
}

packages/guides/tests/unit/Compiler/NodeTransformers/DocumentEntryRegistrationTransformerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use phpDocumentor\Guides\Nodes\ProjectNode;
1111
use phpDocumentor\Guides\Nodes\SectionNode;
1212
use phpDocumentor\Guides\Nodes\TitleNode;
13+
use PHPUnit\Framework\MockObject\Invocation;
1314
use PHPUnit\Framework\TestCase;
1415
use Psr\Log\LoggerInterface;
1516

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
toctrees do not work currently
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
content trees do not work currently
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
toctrees do not work currently
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
toctrees do not work currently

0 commit comments

Comments
 (0)