diff --git a/docs/configuration.rst b/docs/configuration.rst index 0eb22db9..28e4e874 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -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: diff --git a/sphinx_multiversion/main.py b/sphinx_multiversion/main.py index da42216b..274fc7c4 100644 --- a/sphinx_multiversion/main.py +++ b/sphinx_multiversion/main.py @@ -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: @@ -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