Mario Six | 78a88f7 | 2018-07-10 08:40:17 +0200 | [diff] [blame] | 1 | # -*- coding: utf-8; mode: python -*- |
| 2 | # pylint: disable=R0903, C0330, R0914, R0912, E0401 |
| 3 | |
| 4 | import os |
| 5 | import sys |
| 6 | from sphinx.util.pycompat import execfile_ |
| 7 | |
| 8 | # ------------------------------------------------------------------------------ |
| 9 | def 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) |