]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42579: Make workaround for various versions of Sphinx more robust (GH-23662)
authorMatěj Cepl <mcepl@cepl.eu>
Mon, 7 Dec 2020 20:05:13 +0000 (21:05 +0100)
committerGitHub <noreply@github.com>
Mon, 7 Dec 2020 20:05:13 +0000 (20:05 +0000)
The solution in gh#python/cpython#13236 is too strict because it
effectively requires the use of Sphinx >= 2.0. It is not too difficult to
make the same solution more robust so it works with all normal versions
of Sphinx.

Doc/tools/extensions/pyspecific.py

index 80fbd96d56fdc0a6e6076e078d1c259d6a8a15eb..28994399e25cf94e1b4f6513afd3ca9a8c63ace3 100644 (file)
@@ -394,7 +394,12 @@ class DeprecatedRemoved(Directive):
                                    translatable=False)
             node.append(para)
         env = self.state.document.settings.env
-        env.get_domain('changeset').note_changeset(node)
+        # deprecated pre-Sphinx-2 method
+        if hasattr(env, 'note_versionchange'):
+            env.note_versionchange('deprecated', version[0], node, self.lineno)
+        # new method
+        else:
+            env.get_domain('changeset').note_changeset(node)
         return [node] + messages