| 1 |
From: Fabrice Bauzac <[email protected]> |
| 2 |
Date: Sun, 28 Feb 2021 17:28:45 +0100 |
| 3 |
Subject: doc generation: do not require a prior installation |
| 4 |
|
| 5 |
Forwarded: not-needed |
| 6 |
Last-Update: 2021-02-28 |
| 7 |
|
| 8 |
The build of the Sphinx documentation needs to know the version of |
| 9 |
the software. |
| 10 |
|
| 11 |
The upstream package solves this issue by requiring several steps: |
| 12 |
the Python library is built and installed, then the version is |
| 13 |
extracted from the installed library and used for building the |
| 14 |
documentation. |
| 15 |
|
| 16 |
This patch changes the process by extracting the version directly |
| 17 |
from debian/changelog, so that the build of the documentation can be |
| 18 |
done without prior installation of the package. |
| 19 |
--- |
| 20 |
docs/conf.py | 19 +++++++++---------- |
| 21 |
1 file changed, 9 insertions(+), 10 deletions(-) |
| 22 |
|
| 23 |
diff --git a/docs/conf.py b/docs/conf.py |
| 24 |
index f7e3bbb..7dcd272 100644 |
| 25 |
--- a/docs/conf.py |
| 26 |
+++ b/docs/conf.py |
| 27 |
@@ -15,6 +15,7 @@ |
| 28 |
import sys |
| 29 |
import os |
| 30 |
import pkg_resources |
| 31 |
+import re |
| 32 |
|
| 33 |
# If extensions (or modules to document with autodoc) are in another directory, |
| 34 |
# add these directories to sys.path here. If the directory is relative to the |
| 35 |
@@ -63,17 +64,15 @@ author = u'Szczepan Faber, Serhiy Oplakanets, herr.kaste' |
| 36 |
# The full version, including alpha/beta/rc tags. |
| 37 |
# release = u'0.6.1' |
| 38 |
|
| 39 |
-try: |
| 40 |
- release = pkg_resources.get_distribution('mockito').version |
| 41 |
-except pkg_resources.DistributionNotFound: |
| 42 |
- print('mockito must be installed to build the documentation.') |
| 43 |
- print('Install from source using `pip install -e .` in a virtualenv.') |
| 44 |
- sys.exit(1) |
| 45 |
+# Extract the version from debian/changelog. |
| 46 |
+with open("../debian/changelog") as istream: |
| 47 |
+ first_line = istream.readline() |
| 48 |
+ m = re.search(r"\(([0-9.]+)", first_line) |
| 49 |
+ if m: |
| 50 |
+ version = '.'.join(m.group(1).split('.')[:2]) |
| 51 |
+ else: |
| 52 |
+ sys.exit("could not parse first changelog line: " + first_line) |
| 53 |
|
| 54 |
-if 'dev' in release: |
| 55 |
- release = ''.join(release.partition('dev')[:2]) |
| 56 |
- |
| 57 |
-version = '.'.join(release.split('.')[:2]) |
| 58 |
|
| 59 |
# The language for content autogenerated by Sphinx. Refer to documentation |
| 60 |
# for a list of supported languages. |