diff options
author | Adam Turner <9087854+AA-Turner@users.noreply.github.com> | 2023-04-08 07:56:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-08 07:56:20 (GMT) |
commit | 1e9dfdacefa2c8c27762ba6491b0f570147ee355 (patch) | |
tree | e22f8da079134b2fe041f9c0eb184fd27864792c /Doc/tools/extensions | |
parent | a34c79623877a7ed0c86a6d48ddccffa0de76836 (diff) | |
download | cpython-1e9dfdacefa2c8c27762ba6491b0f570147ee355.zip cpython-1e9dfdacefa2c8c27762ba6491b0f570147ee355.tar.gz cpython-1e9dfdacefa2c8c27762ba6491b0f570147ee355.tar.bz2 |
Docs: use Node.findall to avoid a deprecation warning (#99403)
Diffstat (limited to 'Doc/tools/extensions')
-rw-r--r-- | Doc/tools/extensions/c_annotations.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Doc/tools/extensions/c_annotations.py b/Doc/tools/extensions/c_annotations.py index 5af5643..3551bfa 100644 --- a/Doc/tools/extensions/c_annotations.py +++ b/Doc/tools/extensions/c_annotations.py @@ -20,6 +20,7 @@ """ from os import path +import docutils from docutils import nodes from docutils.parsers.rst import directives from docutils.parsers.rst import Directive @@ -41,6 +42,16 @@ REST_ROLE_MAP = { } +# Monkeypatch nodes.Node.findall for forwards compatability +# This patch can be dropped when the minimum Sphinx version is 4.4.0 +# or the minimum Docutils version is 0.18.1. +if docutils.__version_info__ < (0, 18, 1): + def findall(self, *args, **kwargs): + return iter(self.traverse(*args, **kwargs)) + + nodes.Node.findall = findall + + class RCEntry: def __init__(self, name): self.name = name @@ -87,7 +98,7 @@ class Annotations: self.stable_abi_data[name] = record def add_annotations(self, app, doctree): - for node in doctree.traverse(addnodes.desc_content): + for node in doctree.findall(addnodes.desc_content): par = node.parent if par['domain'] != 'c': continue |