diff --git a/sphinx_multiversion/main.py b/sphinx_multiversion/main.py index 9870b314..ea942161 100644 --- a/sphinx_multiversion/main.py +++ b/sphinx_multiversion/main.py @@ -12,6 +12,7 @@ import subprocess import sys import tempfile +import shutil from sphinx import config as sphinx_config from sphinx import project as sphinx_project @@ -30,7 +31,7 @@ def working_dir(path): os.chdir(prev_cwd) -def load_sphinx_config_worker(q, confpath, confoverrides, add_defaults): +def load_sphinx_config_worker(q, confpath, confoverrides): try: with working_dir(confpath): current_config = sphinx_config.Config.read( @@ -38,35 +39,35 @@ def load_sphinx_config_worker(q, confpath, confoverrides, add_defaults): confoverrides, ) - if add_defaults: - current_config.add( - "smv_tag_whitelist", sphinx.DEFAULT_TAG_WHITELIST, "html", str - ) - current_config.add( - "smv_branch_whitelist", - sphinx.DEFAULT_TAG_WHITELIST, - "html", - str, - ) - current_config.add( - "smv_remote_whitelist", - sphinx.DEFAULT_REMOTE_WHITELIST, - "html", - str, - ) - current_config.add( - "smv_released_pattern", - sphinx.DEFAULT_RELEASED_PATTERN, - "html", - str, - ) - current_config.add( - "smv_outputdir_format", - sphinx.DEFAULT_OUTPUTDIR_FORMAT, - "html", - str, - ) - current_config.add("smv_prefer_remote_refs", False, "html", bool) + current_config.add( + "smv_tag_whitelist", sphinx.DEFAULT_TAG_WHITELIST, "html", str + ) + current_config.add( + "smv_branch_whitelist", + sphinx.DEFAULT_TAG_WHITELIST, + "html", + str, + ) + current_config.add( + "smv_remote_whitelist", + sphinx.DEFAULT_REMOTE_WHITELIST, + "html", + str, + ) + current_config.add( + "smv_released_pattern", + sphinx.DEFAULT_RELEASED_PATTERN, + "html", + str, + ) + current_config.add( + "smv_outputdir_format", + sphinx.DEFAULT_OUTPUTDIR_FORMAT, + "html", + str, + ) + current_config.add("smv_prefer_remote_refs", False, "html", bool) + current_config.pre_init_values() current_config.init_values() except Exception as err: @@ -76,7 +77,7 @@ def load_sphinx_config_worker(q, confpath, confoverrides, add_defaults): q.put(current_config) -def load_sphinx_config(confpath, confoverrides, add_defaults=False): +def load_sphinx_config(confpath, confoverrides): q = multiprocessing.Queue() proc = multiprocessing.Process( target=load_sphinx_config_worker, @@ -180,9 +181,7 @@ def main(argv=None): confoverrides[key] = value # Parse config - config = load_sphinx_config( - confdir_absolute, confoverrides, add_defaults=True - ) + config = load_sphinx_config(confdir_absolute, confoverrides) # Get relative paths to root of git repository gitroot = pathlib.Path( @@ -240,6 +239,7 @@ def main(argv=None): # Find config confpath = os.path.join(repopath, confdir) try: + shutil.copy(os.path.join(confdir_absolute, "conf.py"), confpath) current_config = load_sphinx_config(confpath, confoverrides) except (OSError, sphinx_config.ConfigError): logger.error(