]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Set version and release variables in conf.py
authorMichał Kępień <michal@isc.org>
Wed, 29 Dec 2021 08:58:48 +0000 (09:58 +0100)
committerMichał Kępień <michal@isc.org>
Wed, 29 Dec 2021 08:58:48 +0000 (09:58 +0100)
Some Sphinx variables used in the ARM are only set in Makefile.docs.
This works fine when building the ARM using "make", but does not work
with Read the Docs, which only looks at conf.py files.

Since Read the Docs does not run ./configure, renaming conf.py to
conf.py.in and using Autoconf output variables is not a feasible
solution.

Instead, extend doc/arm/conf.py with some Python code which processes
configure.ac using regular expressions and sets the relevant Sphinx
variables accordingly.  As this solution also works fine when building
the ARM using "make", drop the relevant -D options from the list of
sphinx-build options used for building the ARM in Makefile.docs.

Note that the man_SPHINXOPTS counterparts of the removed -D switches are
left intact because doc/man/conf.py is a separate Sphinx project which
is only processed using "make" and duplicating the Python code added to
doc/arm/conf.py by this commit would be inelegant.

Makefile.docs
doc/arm/conf.py

index 3b2700687be68b9c9a4c663b5db69f33dfb95729..fe25d583e022e0dd34649c936a348681825854a1 100644 (file)
@@ -17,9 +17,7 @@ common_SPHINXOPTS =                   \
 
 ALLSPHINXOPTS =                                \
        $(common_SPHINXOPTS)            \
-       -D version="$(PACKAGE_VERSION)" \
        -D today="$(RELEASE_DATE)"      \
-       -D release="$(PACKAGE_VERSION)" \
        $(SPHINXOPTS)                   \
        $(srcdir)
 
index 704c96c5d8ace3d5b92caa59f910defb16be05c2..f7049afe0f4992c9df708c2ce5b68b82ce813e22 100644 (file)
@@ -11,6 +11,8 @@
 
 # flake8: noqa: E501
 
+import re
+
 from typing import List, Tuple
 
 from docutils import nodes
@@ -105,6 +107,21 @@ project = 'BIND 9'
 copyright = '2021, Internet Systems Consortium'
 author = 'Internet Systems Consortium'
 
+m4_vars = {}
+with open('../../configure.ac', encoding='utf-8') as configure_ac:
+    for line in configure_ac:
+        match = re.match(r'm4_define\(\[(?P<key>bind_VERSION_[A-Z]+)\], (?P<val>[^)]*)\)dnl', line)
+        if match:
+            m4_vars[match.group('key')] = match.group('val')
+
+version = '%s.%s.%s%s' % (
+    m4_vars['bind_VERSION_MAJOR'],
+    m4_vars['bind_VERSION_MINOR'],
+    m4_vars['bind_VERSION_PATCH'],
+    m4_vars['bind_VERSION_EXTRA'],
+)
+release = version
+
 # -- General configuration ---------------------------------------------------
 
 # Add any Sphinx extension module names here, as strings. They can be