summaryrefslogtreecommitdiffstats
path: root/Utilities
diff options
context:
space:
mode:
authorHenry Schreiner <henryschreineriii@gmail.com>2023-06-20 21:38:03 (GMT)
committerHenry Schreiner <henryschreineriii@gmail.com>2023-06-22 14:48:50 (GMT)
commit0c14b6085a117af4a1cafa0b1b14aa6ceb343781 (patch)
tree74a9ac4a95b070c35c5f1bbefd40faf1ca8f746e /Utilities
parent0cd5300665fdbb68c32e318e5ca423854716c7a7 (diff)
downloadCMake-0c14b6085a117af4a1cafa0b1b14aa6ceb343781.zip
CMake-0c14b6085a117af4a1cafa0b1b14aa6ceb343781.tar.gz
CMake-0c14b6085a117af4a1cafa0b1b14aa6ceb343781.tar.bz2
Utilities/Sphinx: Fix warning from docutils 0.18.1+
Also might fix 0.18.0 exactly, which apparently forgot to add the backward compat shim.
Diffstat (limited to 'Utilities')
-rw-r--r--Utilities/Sphinx/cmake.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py
index 0afd705..da2609a 100644
--- a/Utilities/Sphinx/cmake.py
+++ b/Utilities/Sphinx/cmake.py
@@ -582,12 +582,23 @@ class CMakeXRefTransform(Transform):
# after the sphinx (210) and docutils (220) substitutions.
default_priority = 221
+ # This helper supports docutils < 0.18, which is missing 'findall',
+ # and docutils == 0.18.0, which is missing 'traverse'.
+ def _document_findall_as_list(self, condition):
+ if hasattr(self.document, 'findall'):
+ # Fully iterate into a list so the caller can grow 'self.document'
+ # while iterating.
+ return list(self.document.findall(condition))
+
+ # Fallback to 'traverse' on old docutils, which returns a list.
+ return self.document.traverse(condition)
+
def apply(self):
env = self.document.settings.env
# Find CMake cross-reference nodes and add index and target
# nodes for them.
- for ref in self.document.traverse(addnodes.pending_xref):
+ for ref in self._document_findall_as_list(addnodes.pending_xref):
if not ref['refdomain'] == 'cmake':
continue