summaryrefslogtreecommitdiffstats
path: root/Utilities
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-06-16 15:58:48 (GMT)
committerBrad King <brad.king@kitware.com>2021-06-17 13:55:56 (GMT)
commit8406d4c1d1d0371c933b6d142b1cd4522c289f83 (patch)
tree6884b91173fb8b168256e8fbb184b21ce1eb7737 /Utilities
parent998fa490f4f9a3f6195f5383276be8e5ce8345c8 (diff)
downloadCMake-8406d4c1d1d0371c933b6d142b1cd4522c289f83.zip
CMake-8406d4c1d1d0371c933b6d142b1cd4522c289f83.tar.gz
CMake-8406d4c1d1d0371c933b6d142b1cd4522c289f83.tar.bz2
Utilities/Sphinx: Index guide section documents for cross-referencing
Extend the change from commit 6185265800 (Utilities/Sphinx: Index guide-level documents for cross-referencing, 2019-12-06, v3.17.0-rc1~181^2~1) to name guide documents other than the top level using their docname instead of their title. This will allow them to be cross-referenced by a stable name even if their title changes.
Diffstat (limited to 'Utilities')
-rw-r--r--Utilities/Sphinx/cmake.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py
index 9fa56cd..9215e14 100644
--- a/Utilities/Sphinx/cmake.py
+++ b/Utilities/Sphinx/cmake.py
@@ -260,6 +260,8 @@ class CMakeTransform(Transform):
# Insert the object link target.
if objtype == 'command':
targetname = title.lower()
+ elif objtype == 'guide' and not tail.endswith('/index'):
+ targetname = tail
else:
if objtype == 'genex':
m = CMakeXRefRole._re_genex.match(title)
@@ -312,6 +314,7 @@ class CMakeXRefRole(XRefRole):
_re = re.compile(r'^(.+?)(\s*)(?<!\x00)<(.*?)>$', re.DOTALL)
_re_sub = re.compile(r'^([^()\s]+)\s*\(([^()]*)\)$', re.DOTALL)
_re_genex = re.compile(r'^\$<([^<>:]+)(:[^<>]+)?>$', re.DOTALL)
+ _re_guide = re.compile(r'^([^<>/]+)/([^<>]*)$', re.DOTALL)
def __call__(self, typ, rawtext, text, *args, **keys):
# Translate CMake command cross-references of the form:
@@ -326,6 +329,10 @@ class CMakeXRefRole(XRefRole):
m = CMakeXRefRole._re_genex.match(text)
if m:
text = '%s <%s>' % (text, m.group(1))
+ elif typ == 'cmake:guide':
+ m = CMakeXRefRole._re_guide.match(text)
+ if m:
+ text = '%s <%s>' % (m.group(2), text)
# CMake cross-reference targets frequently contain '<' so escape
# any explicit `<target>` with '<' not preceded by whitespace.
while True:
@@ -369,6 +376,10 @@ class CMakeXRefTransform(Transform):
continue
objname = ref['reftarget']
+ if objtype == 'guide' and CMakeXRefRole._re_guide.match(objname):
+ # Do not index cross-references to guide sections.
+ continue
+
targetnum = env.new_serialno('index-%s:%s' % (objtype, objname))
targetid = 'index-%s-%s:%s' % (targetnum, objtype, objname)