From 8a567c5982d5c495b5c5a8a796bd1ab85722b2ad Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 30 May 2024 11:57:41 +0200 Subject: [PATCH 1/3] [fix] issue from PR #160 - scripts do miss arguments `sys.argv[1:]` To reproduce the issue read comment [1]. [1] https://github.com/sphinx-doc/sphinx-autobuild/pull/160/files#r1620387971 Closes: https://github.com/sphinx-doc/sphinx-autobuild/issues/162 Signed-off-by: Markus Heiser --- sphinx_autobuild/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx_autobuild/__main__.py b/sphinx_autobuild/__main__.py index c63ddae..6cdb3a2 100644 --- a/sphinx_autobuild/__main__.py +++ b/sphinx_autobuild/__main__.py @@ -27,7 +27,7 @@ def main(argv=()): """Actual application logic.""" colorama.init() - args, build_args = _parse_args(list(argv)) + args, build_args = _parse_args(list(argv) or sys.argv[1:]) src_dir = args.sourcedir out_dir = args.outdir From 050a5f6bb8a96fb1807bb0efee2317c4f2668e75 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 30 May 2024 12:29:42 +0200 Subject: [PATCH 2/3] [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. " From e9193e4c88c3ec4ee46107fc1a2ecb02f43c25e1 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 3 Sep 2024 07:43:41 +0100 Subject: [PATCH 3/3] Update sphinx_autobuild/__main__.py --- sphinx_autobuild/__main__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sphinx_autobuild/__main__.py b/sphinx_autobuild/__main__.py index 6cdb3a2..63a01be 100644 --- a/sphinx_autobuild/__main__.py +++ b/sphinx_autobuild/__main__.py @@ -27,7 +27,11 @@ def main(argv=()): """Actual application logic.""" colorama.init() - args, build_args = _parse_args(list(argv) or sys.argv[1:]) + if not argv: + # entry point functions don't receive args + argv = sys.argv[1:] + + args, build_args = _parse_args(list(argv)) src_dir = args.sourcedir out_dir = args.outdir