summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2020-07-11 10:20:26 -0300
committerDavid Bremner <david@tethera.net>2020-07-15 08:32:15 -0300
commit0e03e2d45e36edb635229f356bf41f153c30a70f (patch)
tree523cef4c6c6be805f06bff83b4fc5eee1eef78ff /doc
parent78e9b3467d9f09228a444bb2eec93e4c765b7e9b (diff)
doc: replace use of environment variables with a generated config
It is getting unwieldy to pass configuration options on the sphinx-build command line, and I anticipate further use of conditionals. As far as I could tell, execing a string is the idiomatic way to emulate include in Python.
Diffstat (limited to 'doc')
-rw-r--r--doc/Makefile.local2
-rw-r--r--doc/conf.py11
2 files changed, 9 insertions, 4 deletions
diff --git a/doc/Makefile.local b/doc/Makefile.local
index 19b953ed..30411341 100644
--- a/doc/Makefile.local
+++ b/doc/Makefile.local
@@ -4,7 +4,7 @@ dir := doc
# You can set these variables from the command line.
SPHINXOPTS := -q
-SPHINXBUILD = WITH_EMACS=${WITH_EMACS} RSTI_DIR=$(realpath emacs) sphinx-build
+SPHINXBUILD = sphinx-build
DOCBUILDDIR := $(dir)/_build
# Internal variables.
diff --git a/doc/conf.py b/doc/conf.py
index 70987ac5..fdff2a2c 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -22,6 +22,13 @@ for pathdir in ['.', '..']:
with open(version_file,'r') as infile:
version=infile.read().replace('\n','')
+# read generated config
+for pathdir in ['.', '..']:
+ conf_file = os.path.join(location,pathdir,'sphinx.config')
+ if os.path.exists(conf_file):
+ with open(conf_file,'r') as infile:
+ exec(''.join(infile.readlines()))
+
# The full version, including alpha/beta/rc tags.
release = version
@@ -29,12 +36,10 @@ release = version
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
-if os.environ.get('WITH_EMACS') == '1':
+if tags.has('WITH_EMACS'):
# Hacky reimplementation of include to workaround limitations of
# sphinx-doc
lines = ['.. include:: /../emacs/rstdoc.rsti\n\n'] # in the source tree
- rsti_dir = os.environ.get('RSTI_DIR')
- # the other files are from the build tree
for file in ('notmuch.rsti', 'notmuch-lib.rsti', 'notmuch-show.rsti', 'notmuch-tag.rsti'):
lines.extend(open(rsti_dir+'/'+file))
rst_epilog = ''.join(lines)