Skip to content

Commit 6a02df6

Browse files
committed
[BUGFIX] Fix generated menu when progress bar is active
The progress bar turns the $documents array into an iterator that can only be iterated once and is empty thereafter. We need to use the iterator to render each document so that the progress bar works, but the array to pass to the render context.
1 parent 58d85c2 commit 6a02df6

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

docs/include.rst.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
.. documentblock::
2-
:identifier: mainmenu
3-
4-
.. rubric:: My Header
5-
6-
.. menu::
7-
:menu: mainmenu
8-
9-
/*
10-
/*/index
11-
121
.. documentblock::
132
:identifier: navbar
143

packages/guides-cli/src/Command/Run.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
173173
$this->commandBus->handle(
174174
new RenderCommand(
175175
$format,
176+
$documents,
176177
$progressBar === null ? $documents : $progressBar->iterate($documents),
177178
$sourceFileSystem,
178179
$destinationFileSystem,

packages/guides/src/Handlers/RenderCommand.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010

1111
final class RenderCommand
1212
{
13-
/** @param iterable<DocumentNode> $documents */
13+
/**
14+
* @param DocumentNode[] $documentArray
15+
* @param iterable<DocumentNode> $documentIterator
16+
*/
1417
public function __construct(
1518
private readonly string $outputFormat,
16-
private readonly iterable $documents,
19+
private readonly array $documentArray,
20+
private readonly iterable $documentIterator,
1721
private readonly FilesystemInterface $origin,
1822
private readonly FilesystemInterface $destination,
1923
private readonly ProjectNode $projectNode,
@@ -26,10 +30,16 @@ public function getOutputFormat(): string
2630
return $this->outputFormat;
2731
}
2832

29-
/** @return iterable<DocumentNode> */
30-
public function getDocuments(): iterable
33+
/** @return DocumentNode[] $documentArray */
34+
public function getDocumentArray(): array
3135
{
32-
return $this->documents;
36+
return $this->documentArray;
37+
}
38+
39+
/** @return iterable<DocumentNode> $documentIterator */
40+
public function getDocumentIterator(): iterable
41+
{
42+
return $this->documentIterator;
3343
}
3444

3545
public function getOrigin(): FilesystemInterface

packages/guides/src/Renderer/BaseTypeRenderer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ public function __construct(
1919

2020
public function render(RenderCommand $renderCommand): void
2121
{
22-
foreach ($renderCommand->getDocuments() as $document) {
22+
foreach ($renderCommand->getDocumentIterator() as $document) {
2323
$this->commandBus->handle(
2424
new RenderDocumentCommand(
2525
$document,
2626
RenderContext::forDocument(
2727
$document,
28-
(array) $renderCommand->getDocuments(),
28+
$renderCommand->getDocumentArray(),
2929
$renderCommand->getOrigin(),
3030
$renderCommand->getDestination(),
3131
$renderCommand->getDestinationPath(),

0 commit comments

Comments
 (0)