Skip to content

Commit

Permalink
[fix] interaction with autodoc plugin / sphinx-build in subprocess
Browse files Browse the repository at this point in the history
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: sphinx-doc#31 (comment)
Closes: sphinx-doc#148

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
  • Loading branch information
return42 committed May 30, 2024
1 parent 8a567c5 commit f440a74
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions sphinx_autobuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -31,13 +28,11 @@ 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:
show(command=["sphinx-build"] + self.sphinx_args)
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. "
Expand Down

0 comments on commit f440a74

Please sign in to comment.