mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
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.
This commit is contained in:
parent
78e9b3467d
commit
0e03e2d45e
3 changed files with 17 additions and 4 deletions
8
configure
vendored
8
configure
vendored
|
@ -1548,6 +1548,14 @@ NOTMUCH_HAVE_PYTHON3_PYTEST=${have_python3_pytest}
|
|||
PLATFORM=${platform}
|
||||
EOF
|
||||
|
||||
cat > sphinx.config <<EOF
|
||||
# Generated by configure, run from doc/conf.py
|
||||
EOF
|
||||
if [ $WITH_EMACS = "1" ]; then
|
||||
printf "tags.add('WITH_EMACS')\n" >> sphinx.config
|
||||
fi
|
||||
printf "rsti_dir = '%s'\n" $(realpath emacs) >> sphinx.config
|
||||
|
||||
# Finally, after everything configured, inform the user how to continue.
|
||||
cat <<EOF
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
11
doc/conf.py
11
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)
|
||||
|
|
Loading…
Reference in a new issue