[PATCH 1/2] doc: pass specified configure options as tags to Sphinx

Jani Nikula jani at nikula.org
Sat Jan 11 04:09:14 PST 2020


Add generic support for passing enabled configure options as tags to
Sphinx. Add TAGS make variable to specify the configure options, and
use the sphinx-build -t option to add the options equal to 1 as tags.

The tags may be used in conf.py to conditionally adjust the
configuration [1], and to conditionally include content blocks in rst
files using the Sphinx "only" directive [2].

Initially, convert WITH_EMACS to a tag.

[1] https://www.sphinx-doc.org/en/master/usage/configuration.html#conf-tags
[2] https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#tags
---
 doc/Makefile.local | 9 +++++++--
 doc/conf.py        | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/doc/Makefile.local b/doc/Makefile.local
index b4e0c9558101..c78aea49a108 100644
--- a/doc/Makefile.local
+++ b/doc/Makefile.local
@@ -4,11 +4,16 @@ dir := doc
 
 # You can set these variables from the command line.
 SPHINXOPTS    := -q
-SPHINXBUILD   = WITH_EMACS=${WITH_EMACS} sphinx-build
+SPHINXBUILD   = sphinx-build
 DOCBUILDDIR      := $(dir)/_build
 
+# Configure options to be added as Sphinx tags.
+# Add "-t <tag>" for each make variable in TAGS that equals 1.
+TAGS := WITH_EMACS
+TAGOPTS := $(patsubst %=1,-t %,$(filter %=1,$(foreach tag,$(TAGS),$(tag)=$(value $(tag)))))
+
 # Internal variables.
-ALLSPHINXOPTS   := $(SPHINXOPTS) $(srcdir)/$(dir)
+ALLSPHINXOPTS   := $(SPHINXOPTS) $(TAGOPTS) $(srcdir)/$(dir)
 APIMAN		:= $(DOCBUILDDIR)/man/man3/notmuch.3
 DOXYFILE	:= $(srcdir)/$(dir)/doxygen.cfg
 
diff --git a/doc/conf.py b/doc/conf.py
index fc9738ff092a..2ee063d77f10 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -32,7 +32,7 @@ exclude_patterns = ['_build']
 # If we don't have emacs (or the user configured --without-emacs),
 # don't build the notmuch-emacs docs, as they need emacs to generate
 # the docstring include files
-if os.environ.get('WITH_EMACS') != '1':
+if not tags.has('WITH_EMACS'):
     exclude_patterns.append('notmuch-emacs.rst')
 
 # The name of the Pygments (syntax highlighting) style to use.
-- 
2.20.1



More information about the notmuch mailing list