Skip to content

Commit

Permalink
Add smv_postbuild_command config option
Browse files Browse the repository at this point in the history
  • Loading branch information
samtygier-stfc committed Oct 10, 2024
1 parent e61ff44 commit 1cf86c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ Here are some examples:
git for-each-ref --format "%(refname)"
Prebuild command
Pre and post-build command
================

In some cases it may be necessary to run a command in the checked out directory before building with sphinx. For example if you are using ``sphinx-apidoc`` to generate the autodoc api source files.
In some cases it may be necessary to run a command in the checked out directory before or after building with sphinx. For example if you are using ``sphinx-apidoc`` to generate the autodoc api source files.

The options ``smv_prebuild_command`` and ``smv_postbuild_command`` are provided.

For example:

Expand Down
10 changes: 10 additions & 0 deletions sphinx_multiversion/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def load_sphinx_config_worker(q, confpath, confoverrides, add_defaults):
)
current_config.add("smv_prefer_remote_refs", False, "html", bool)
current_config.add("smv_prebuild_command", "", "html", str)
current_config.add("smv_postbuild_command", "", "html", str)
current_config.pre_init_values()
current_config.init_values()
except Exception as err:
Expand Down Expand Up @@ -387,4 +388,13 @@ def main(argv=None):
)
subprocess.check_call(cmd, cwd=current_cwd, env=env)

if config.smv_postbuild_command != "":
logger.debug(
"Running postbuild command: %r",
config.smv_postbuild_command,
)
subprocess.check_call(
config.smv_postbuild_command, cwd=current_cwd, shell=True
)

return 0

0 comments on commit 1cf86c4

Please sign in to comment.