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 May 26, 2021
1 parent 5d85ba7 commit 46e20cc
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)" | sed 's/^refs\///g'
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 @@ -68,6 +68,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 @@ -361,4 +362,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 46e20cc

Please sign in to comment.