1# -*- coding: utf-8; mode: python -*- 2# pylint: disable=R0903, C0330, R0914, R0912, E0401 3 4import os 5import sys 6from sphinx.util.pycompat import execfile_ 7 8# ------------------------------------------------------------------------------ 9def loadConfig(namespace): 10# ------------------------------------------------------------------------------ 11 12 u"""Load an additional configuration file into *namespace*. 13 14 The name of the configuration file is taken from the environment 15 ``SPHINX_CONF``. The external configuration file extends (or overwrites) the 16 configuration values from the origin ``conf.py``. With this you are able to 17 maintain *build themes*. """ 18 19 config_file = os.environ.get("SPHINX_CONF", None) 20 if (config_file is not None 21 and os.path.normpath(namespace["__file__"]) != os.path.normpath(config_file) ): 22 config_file = os.path.abspath(config_file) 23 24 if os.path.isfile(config_file): 25 sys.stdout.write("load additional sphinx-config: %s\n" % config_file) 26 config = namespace.copy() 27 config['__file__'] = config_file 28 execfile_(config_file, config) 29 del config['__file__'] 30 namespace.update(config) 31 else: 32 sys.stderr.write("WARNING: additional sphinx-config not found: %s\n" % config_file) 33