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 authored and Markus committed Sep 3, 2024
1 parent 8a567c5 commit 050a5f6
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 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 Down Expand Up @@ -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. "
Expand Down

0 comments on commit 050a5f6

Please sign in to comment.