aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/sphinx/load_config.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarIT.de>2016-08-13 10:12:42 -0400
committerJonathan Corbet <corbet@lwn.net>2016-08-14 13:51:51 -0400
commit606b9ac81a63ab3adb7e61206b9ae34ee186a89d (patch)
tree8ff0fcf5ec5d762a0ad7fc7e05fbbeb8d17f6801 /Documentation/sphinx/load_config.py
parent3eb6cd6834c356f40e1633a0ced4ff9a4c59936b (diff)
doc-rst: generic way to build only sphinx sub-folders
Add a generic way to build only a reST sub-folder with or without a individual *build-theme*. * control *sub-folders* by environment SPHINXDIRS * control *build-theme* by environment SPHINX_CONF Folders with a conf.py file, matching $(srctree)/Documentation/*/conf.py can be build and distributed *stand-alone*. E.g. to compile only the html of 'media' and 'gpu' folder use:: make SPHINXDIRS="media gpu" htmldocs To use an additional sphinx-build configuration (*build-theme*) set the name of the configuration file to SPHINX_CONF. E.g. to compile only the html of 'media' with the *nit-picking* build use:: make SPHINXDIRS=media SPHINX_CONF=conf_nitpick.py htmldocs With this, the Documentation/conf.py is read first and updated with the configuration values from the Documentation/media/conf_nitpick.py. Signed-off-by: Markus Heiser <markus.heiser@darmarIT.de> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'Documentation/sphinx/load_config.py')
-rw-r--r--Documentation/sphinx/load_config.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/Documentation/sphinx/load_config.py b/Documentation/sphinx/load_config.py
new file mode 100644
index 000000000000..301a21aa4f63
--- /dev/null
+++ b/Documentation/sphinx/load_config.py
@@ -0,0 +1,32 @@
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)