bpo-42579: Make workaround for various versions of Sphinx more robust (GH-23662)

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.
This commit is contained in:
Matěj Cepl 2020-12-07 21:05:13 +01:00 committed by GitHub
parent c0afb7fa0e
commit b63a620014
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -394,7 +394,12 @@ class DeprecatedRemoved(Directive):
translatable=False) translatable=False)
node.append(para) node.append(para)
env = self.state.document.settings.env 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 return [node] + messages