]> git.notmuchmail.org Git - notmuch/commitdiff
doc: fix for out-of-tree builds of notmuch-emacs docs
authorDavid Bremner <david@tethera.net>
Sun, 31 May 2020 16:15:03 +0000 (13:15 -0300)
committerDavid Bremner <david@tethera.net>
Mon, 1 Jun 2020 12:07:50 +0000 (09:07 -0300)
The sphinx-doc include directive does not have the ability to include
files from the build tree, so we replace the include with reading the
files in conf.py. The non-trivial downside of this is that the emacs
docstrings are now defined for every rst source file. They are
namespaced with docstring::, so hopefully there will not be any
surprises. One thing that is noticable is a small (absolute) time
penalty in running sphinx-doc.

doc/Makefile.local
doc/conf.py
doc/notmuch-emacs.rst

index b4e0c9558101a81bcc0fb65b201b42f6c1e7c850..769438ed24756962d34d8b99348df1e0b2d93eac 100644 (file)
@@ -4,7 +4,7 @@ dir := doc
 
 # You can set these variables from the command line.
 SPHINXOPTS    := -q
 
 # You can set these variables from the command line.
 SPHINXOPTS    := -q
-SPHINXBUILD   = WITH_EMACS=${WITH_EMACS} sphinx-build
+SPHINXBUILD   = WITH_EMACS=${WITH_EMACS} RSTI_DIR=$(realpath emacs) sphinx-build
 DOCBUILDDIR      := $(dir)/_build
 
 # Internal variables.
 DOCBUILDDIR      := $(dir)/_build
 
 # Internal variables.
index fc9738ff092a72542d1465b0420cf5e6e65f9885..ffb8ca1f662dca056af2075bf75a383daf72d5ae 100644 (file)
@@ -29,10 +29,20 @@ release = version
 # directories to ignore when looking for source files.
 exclude_patterns = ['_build']
 
 # directories to ignore when looking for source files.
 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 os.environ.get('WITH_EMACS') == '1':
+    # 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)
+    del lines
+else:
+    # 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
     exclude_patterns.append('notmuch-emacs.rst')
 
 # The name of the Pygments (syntax highlighting) style to use.
     exclude_patterns.append('notmuch-emacs.rst')
 
 # The name of the Pygments (syntax highlighting) style to use.
index 1655e2f0a7ad5b160130580f0e9463706b803e72..de47b72688e3a07a96fd4c925e2a833e1e41311f 100644 (file)
@@ -377,13 +377,3 @@ suffix exist it will be read instead (just one of these, chosen in this
 order). Most often users create ``~/.emacs.d/notmuch-config.el`` and just
 work with it. If Emacs was invoked with the ``-q`` or ``--no-init-file``
 options, ``notmuch-init-file`` is not read.
 order). Most often users create ``~/.emacs.d/notmuch-config.el`` and just
 work with it. If Emacs was invoked with the ``-q`` or ``--no-init-file``
 options, ``notmuch-init-file`` is not read.
-
-.. include:: ../emacs/rstdoc.rsti
-
-.. include:: ../emacs/notmuch.rsti
-
-.. include:: ../emacs/notmuch-lib.rsti
-
-.. include:: ../emacs/notmuch-show.rsti
-
-.. include:: ../emacs/notmuch-tag.rsti