Docs: use Node.findall to avoid a deprecation warning (#99403)

This commit is contained in:
Adam Turner 2023-04-08 08:56:20 +01:00 committed by GitHub
parent a34c796238
commit 1e9dfdacef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -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