summaryrefslogtreecommitdiffstats
path: root/Utilities/Sphinx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-06-23 14:46:02 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-06-23 14:46:29 (GMT)
commit8801ce34c162411a19438c01828cae42cb01a5cb (patch)
treebd3f63ca9d639d5d12794b54b72f5d827f4c1ef9 /Utilities/Sphinx
parent052e95236238d8614df0ff4f68dced0eb1544118 (diff)
parent0c14b6085a117af4a1cafa0b1b14aa6ceb343781 (diff)
downloadCMake-8801ce34c162411a19438c01828cae42cb01a5cb.zip
CMake-8801ce34c162411a19438c01828cae42cb01a5cb.tar.gz
CMake-8801ce34c162411a19438c01828cae42cb01a5cb.tar.bz2
Merge topic 'sphinx-docutils-warning' into release-3.27
0c14b6085a Utilities/Sphinx: Fix warning from docutils 0.18.1+ Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8578
Diffstat (limited to 'Utilities/Sphinx')
-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 67dcec7..60bfb33 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