Skip to content

Add a progress bar with a maximum for the rendering phase#208

Open
Amoifr wants to merge 1 commit into
symfony-tools:mainfrom
Amoifr:fix-19-render-progress-bar
Open

Add a progress bar with a maximum for the rendering phase#208
Amoifr wants to merge 1 commit into
symfony-tools:mainfrom
Amoifr:fix-19-render-progress-bar

Conversation

@Amoifr

@Amoifr Amoifr commented Jul 11, 2026

Copy link
Copy Markdown

Fixes #19, and removes the // TODO: create a proper progress bar for rendering in BuildProgressListener.

Today the parsing phase gets a real progress bar, while rendering only prints a static note:

 ! [NOTE] Rendering the HTML files...

Now it gets a bar that knows where it's going:

 ! [NOTE] Rendering 3 HTML files

 3/3 [============================] 100%

How, since the parser has no per-document render event. Documents::render() loops over the documents without dispatching anything, and DocumentNode::renderDocument() bypasses Node::render(), so there's no "document rendered" signal to hook into. But there is enough to work with:

  • the maximum comes from PreBuildRenderEventgetBuilder()->getDocuments()->getAll(), which is exactly the set of documents about to be rendered;
  • the progress is tracked on POST_NODE_RENDER by looking at the file each rendered node belongs to, advancing once per file — the same "files already seen" approach the parsing bar already uses in postParseDocument();
  • the bar is finished on POST_BUILD_RENDER.

Nodes are also rendered outside the rendering phase, so the listener ignores them until the bar exists.

Tests: BuildDocsCommandTest now asserts both bars announce their file count and reach it. Verified the assertions fail without the change (the output only contains the old static note). Full suite green: 68 tests, 157 assertions.


Unrelated, but I ran into it while testing this and it seems worth flagging: bin/docs-builder is currently broken on Symfony 8 — Application::add() was removed in favour of addCommand(), so the binary dies immediately:

PHP Fatal error: Call to undefined method Symfony\Component\Console\Application::add() in src/Application.php:38

The test suite doesn't catch it because it drives the command through CommandTester rather than the binary. Happy to send a separate PR if you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Fix the progress bar in build:docs command

1 participant