From 050a5f6bb8a96fb1807bb0efee2317c4f2668e75 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 30 May 2024 12:29:42 +0200 Subject: [PATCH] [fix] interaction with autodoc plugin / sphinx-build in subprocess To update changes to the doc strings (autodoc) in the source code in the HTML output, the sphinx-build must not run in the same process as the server / sphinx-build must run in a subprocess so that changed source code is re-imported. This issue was introduced in commit d57f117 / a commit without a PR & review. Related: https://github.com/sphinx-doc/sphinx-autobuild/issues/31#issuecomment-111232175 Closes: https://github.com/sphinx-doc/sphinx-autobuild/issues/148 Signed-off-by: Markus Heiser --- sphinx_autobuild/build.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/sphinx_autobuild/build.py b/sphinx_autobuild/build.py index 0859dc3..2c0adc4 100644 --- a/sphinx_autobuild/build.py +++ b/sphinx_autobuild/build.py @@ -2,9 +2,6 @@ import subprocess -# This isn't public API, but we want to avoid a subprocess call -from sphinx.cmd.build import build_main - from sphinx_autobuild.utils import show @@ -32,12 +29,10 @@ def __call__(self, *, rebuild: bool = True): raise show(command=["sphinx-build"] + self.sphinx_args) - - # NOTE: - # sphinx.cmd.build.build_main is not considered to be public API, - # but as this is a first-party project, we can cheat a little bit. - if return_code := build_main(self.sphinx_args): - print(f"Sphinx exited with exit code: {return_code}") + try: + subprocess.run(["sphinx-build"] + self.sphinx_args, check=True) + except subprocess.CalledProcessError as e: + print(f"Sphinx exited with exit code: {e.returncode}") print( "The server will continue serving the build folder, but the contents " "being served are no longer in sync with the documentation sources. "