]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Support Sphinx 1.6.7
authorPetr Špaček <pspacek@isc.org>
Wed, 20 Jul 2022 16:44:48 +0000 (18:44 +0200)
committerPetr Špaček <pspacek@isc.org>
Thu, 21 Jul 2022 13:26:26 +0000 (15:26 +0200)
Luckily we don't rely on SphinxDirective functionality which does not
exist in 1.6.7. Replace it with docutils Directive.

transform_content() callback was added only in Sphinx 3.0.0.
Detect if it was not called and call it manually.
The transform_content() function requires access to inner "contentnode"
which is created inside run(). This workaround relies on the order of
node as it was in the pre-3.0.0 versions, but it should not matter as
new versions will not trigger the workaround.

(cherry picked from commit 8796ad7fe8ed24d1287bfd94ef1ee283d778c047)

doc/arm/_ext/iscconf.py

index 10c24040fec5743a037fcb08da3f79a1698ca012..b5bd966e2a95811053740e9be128aaa75ee92faf 100644 (file)
@@ -23,7 +23,7 @@ https://www.sphinx-doc.org/en/master/development/tutorials/recipe.html
 
 from collections import namedtuple
 
-from docutils.parsers.rst import directives
+from docutils.parsers.rst import Directive, directives
 from docutils import nodes
 
 from sphinx import addnodes
@@ -31,7 +31,6 @@ from sphinx.directives import ObjectDescription
 from sphinx.domains import Domain
 from sphinx.roles import XRefRole
 from sphinx.util import logging
-from sphinx.util.docutils import SphinxDirective
 from sphinx.util.nodes import make_refnode
 
 import checkgrammar
@@ -61,7 +60,7 @@ def domain_factory(domainname, domainlabel, todolist, grammar):
                     See StatementListDirective.
     """
 
-    class StatementListDirective(SphinxDirective):
+    class StatementListDirective(Directive):
         """A custom directive to generate list of statements.
         It only installs placeholder which is later replaced by
         process_statementlist_nodes() callback.
@@ -229,6 +228,7 @@ def domain_factory(domainname, domainlabel, todolist, grammar):
 
             def transform_content(self, contentnode: addnodes.desc_content) -> None:
                 """autogenerate content from structured data"""
+                self.workaround_transform_content = True
                 if self.isc_short:
                     contentnode.insert(0, self.isc_short_node)
                 if self.isc_tags:
@@ -263,6 +263,19 @@ def domain_factory(domainname, domainlabel, todolist, grammar):
                 if len(warn):
                     contentnode.insert(0, warn)
 
+            def __init__(self, *args, **kwargs):
+                """Compability with Sphinx < 3.0.0"""
+                self.workaround_transform_content = False
+                super().__init__(*args, **kwargs)
+
+            def run(self):
+                """Compability with Sphinx < 3.0.0"""
+                nodelist = super().run()
+                if not self.workaround_transform_content:
+                    # get access to "contentnode" created inside super.run()
+                    self.transform_content(nodelist[1][-1])
+                return nodelist
+
         name = domainname
         label = domainlabel