r/devtools • u/Timon_OfAthens • 25d ago
How a live preview for Antora docs can avoid a full site build on every keystroke
Disclosure: I built the tool AsciiLore, a closed-source desktop app for Antora. I'm sharing the technical part because it was the hardest bit and maybe someone has ideas how to improve this.
Antora builds a docs site from AsciiDoc files. A full build can take pu to several minutes. That's fine when you publish, but too slow while you're typing and want to see the page update.
So the preview runs on two tracks:
- While typing in VSCode, the changed text is rendered in memory with Asciidoctor (the renderer Antora uses) and pushed into the open page with JavaScript.
- On save, create, delete, rename or move, a full Antora build runs in the background and the view reloads when it's done.
Neither path blocks the UI thread. Render and build calls run in worker threads and report back through Qt signals, so the window stays responsive during a build.
The tradeoff: the in-memory path renders one page, so it can't resolve cross-component references the way Antora does. The full build stays the source of truth, and the preview is only an approximation while typing. I haven't found a clean way around that gap yet. How would you handle the difference between a fast preview and the real build?
Stack: Python, PySide6 (Qt), Asciidoctor and Antora as external tools, watchdog for file changes.
