From 8f14aef403387144e87a1fb01b8242a806695e4e Mon Sep 17 00:00:00 2001 From: Adrian Vollmer Date: Mon, 29 Apr 2024 10:14:34 +0200 Subject: [PATCH] Ensure zundler runs last when building with sphinx --- src/zundler/sphinxext/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/zundler/sphinxext/__init__.py b/src/zundler/sphinxext/__init__.py index f96b909..148a1cd 100644 --- a/src/zundler/sphinxext/__init__.py +++ b/src/zundler/sphinxext/__init__.py @@ -26,9 +26,7 @@ class ZundlerBuilder(StandaloneHTMLBuilder): self.app.original_outdir ) - def finish(self): - super().finish() - + def run_zundler(self): from zundler.embed import embed_assets root_doc = self.config.zundler_root_doc @@ -54,6 +52,10 @@ class ZundlerBuilder(StandaloneHTMLBuilder): ) +def run_zundler(app, exception): + app.builder.run_zundler() + + def setup(app): # Fix the outdir. We want to build the files into $builddir/html first, # then $builddir/$target second. @@ -94,6 +96,10 @@ def setup(app): app.add_builder(ZundlerBuilder) + # This should run as the last function in the build-finished event + # Set a high priority and hope nothing is higher + app.connect("build-finished", run_zundler, priority=2**32) + return { "version": "0.1", "parallel_read_safe": True,