]> 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:59:38 +0000 (09:59 +0100)
Some Sphinx variables used in the ARM are only set in
doc/arm/Makefile.in.  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
the "version" file 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
doc/arm/Makefile.in.

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.

(cherry picked from commit 38d251e11b01f53f74b7e0bfc052e995c93aac1a)

doc/arm/Makefile.in
doc/arm/conf.py

index fba3cee7fcbf10ab64388f522188a12fc950f985..146f157813606f4268ef5b009db6919dc8dffce4 100644 (file)
@@ -34,9 +34,7 @@ common_SPHINXOPTS =   \
 
 ALLSPHINXOPTS =                                \
        $(common_SPHINXOPTS)                    \
-       -D version="${BIND9_VERSION}"           \
        -D today="${RELEASE_DATE}"              \
-       -D release="${BIND9_VERSIONSTRING}"     \
        $(SPHINXOPTS)                           \
        ${srcdir}
 
index 0503f1eb6abac88105c5239449b1e11bbd24b1a2..7260a88b886377b63530ae70253c656a5768d124 100644 (file)
@@ -11,6 +11,8 @@
 
 # flake8: noqa: E501
 
+import re
+
 from typing import List, Tuple
 
 from docutils import nodes
@@ -105,6 +107,23 @@ project = 'BIND 9'
 copyright = '2021, Internet Systems Consortium'
 author = 'Internet Systems Consortium'
 
+version_vars = {}
+with open('../../version', encoding='utf-8') as version_file:
+    for line in version_file:
+        match = re.match(r'(?P<key>[A-Z]+)=(?P<val>.*)', line)
+        if match:
+            version_vars[match.group('key')] = match.group('val')
+
+version = '%s.%s.%s%s%s%s' % (
+    version_vars['MAJORVER'],
+    version_vars['MINORVER'],
+    version_vars['PATCHVER'],
+    version_vars['RELEASETYPE'],
+    version_vars['RELEASEVER'],
+    version_vars['EXTENSIONS'],
+)
+release = version
+
 # -- General configuration ---------------------------------------------------
 
 # Add any Sphinx extension module names here, as strings. They can be