1 # -*- coding: utf-8; mode: python -*-
2 # pylint: disable=R0903, C0330, R0914, R0912, E0401
6 from sphinx.util.osutil import fs_encoding
8 # ------------------------------------------------------------------------------
9 def loadConfig(namespace):
10 # ------------------------------------------------------------------------------
12 u"""Load an additional configuration file into *namespace*.
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*. """
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)
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 with open(config_file, 'rb') as f:
29 code = compile(f.read(), fs_encoding, 'exec')
31 del config['__file__']
32 namespace.update(config)
34 sys.stderr.write("WARNING: additional sphinx-config not found: %s\n" % config_file)