From c48aa1998c5bcddb413f3fb2953fc941ce88ed03 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Mon, 3 Apr 2023 00:45:48 +0200
Subject: [PATCH] fix(doc): Setup function not always running
If the sphinx version was below 1.8.5, no setup function was defined at
all.
---
doc/conf.py | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/doc/conf.py b/doc/conf.py
index 7a11d37b..df345396 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -238,6 +238,19 @@ epub_exclude_files = ['search.html']
# The 'versionadded' and 'versionchanged' directives are overridden.
suppress_warnings = ['app.add_directive']
+
+def setup(app):
+ sys.path.insert(0, os.path.abspath(doc_path))
+ from configdomain import myDomain
+ app.add_domain(myDomain)
+
+ try:
+ inject_version_directives(app)
+ except NameError:
+ # Function was not defined because sphinx version was too low
+ pass
+
+
# It is not exactly clear in which version the VersionChange class was
# introduced, but we know it is available in at least 1.8.5.
# This feature is mainly needed for the online docs on readthedocs for the docs
@@ -250,13 +263,10 @@ if packaging.version.parse(sphinx.__version__) >= packaging.version.parse("1.8.5
from docutils.nodes import Node
from sphinx.domains.changeset import VersionChange
- def setup(app):
+ def inject_version_directives(app):
app.add_directive('deprecated', VersionDirective)
app.add_directive('versionadded', VersionDirective)
app.add_directive('versionchanged', VersionDirective)
- sys.path.insert(0, os.path.abspath(doc_path))
- from configdomain import myDomain
- app.add_domain(myDomain)
class VersionDirective(VersionChange):
"""