From be1a4df2652dfbeef24e356364efb2e7e6ecf50b Mon Sep 17 00:00:00 2001 From: Alexander Lanin Date: Sun, 17 Nov 2024 22:46:58 +0100 Subject: [PATCH] Postpone diagnostic collection until everything was emitted --- lib/esbonio/changes/925.fix.md | 1 + lib/esbonio/esbonio/sphinx_agent/handlers/diagnostics.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 lib/esbonio/changes/925.fix.md diff --git a/lib/esbonio/changes/925.fix.md b/lib/esbonio/changes/925.fix.md new file mode 100644 index 000000000..7c39d2088 --- /dev/null +++ b/lib/esbonio/changes/925.fix.md @@ -0,0 +1 @@ +The sphinx agent should now be able to collect diagnostics from extensions that make use of the `build-finished` event e.g. sphinx-needs by @AlexanderLanin diff --git a/lib/esbonio/esbonio/sphinx_agent/handlers/diagnostics.py b/lib/esbonio/esbonio/sphinx_agent/handlers/diagnostics.py index a18ab00a1..1a80a4780 100644 --- a/lib/esbonio/esbonio/sphinx_agent/handlers/diagnostics.py +++ b/lib/esbonio/esbonio/sphinx_agent/handlers/diagnostics.py @@ -45,4 +45,8 @@ def setup(app: Sphinx): # TODO: Support for Sphinx v7+ # app.connect("include-read") - app.connect("build-finished", sync_diagnostics) + # sync_diagnostics needs to run after all diagnostics have been emitted. + # This ensures proper synchronization of data, as some extensions, like + # sphinx-needs, emit diagnostics during the "build-finished" event. + # Setting priority to 900 ensures this handler runs after typical operations. + app.connect("build-finished", sync_diagnostics, priority=900)