summaryrefslogtreecommitdiffstats
path: root/Utilities
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-14 19:05:39 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-03-14 19:05:47 (GMT)
commite80bc8787eec15d70ff24cac4d3887fc95f4b700 (patch)
tree003fc0471f593a76b37481f18c34ae41bbe589cd /Utilities
parent797141606e838a2cfb79e0d079451484a3e2a750 (diff)
parentc8679f05715380ce253bb65e64763b68dd96ad35 (diff)
downloadCMake-e80bc8787eec15d70ff24cac4d3887fc95f4b700.zip
CMake-e80bc8787eec15d70ff24cac4d3887fc95f4b700.tar.gz
CMake-e80bc8787eec15d70ff24cac4d3887fc95f4b700.tar.bz2
Merge topic 'doc-command-link-text'
c8679f0571 Utilities/Sphinx: Restore trailing parens on command cross-references Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8326
Diffstat (limited to 'Utilities')
-rw-r--r--Utilities/Sphinx/cmake.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py
index 38fd98a..ba1fa4a 100644
--- a/Utilities/Sphinx/cmake.py
+++ b/Utilities/Sphinx/cmake.py
@@ -486,14 +486,19 @@ class CMakeXRefRole(XRefRole):
# See sphinx.util.nodes.explicit_title_re; \x00 escapes '<'.
_re = re.compile(r'^(.+?)(\s*)(?<!\x00)<(.*?)>$', re.DOTALL)
- _re_ref = re.compile(r'^.*\s<\w+([(][\w\s]+[)])?>$', 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):
if typ == 'cmake:command':
- m = CMakeXRefRole._re_ref.match(text)
- if m is None:
+ # Translate a CMake command cross-reference of the form:
+ # `command_name(SUB_COMMAND)`
+ # to be its own explicit target:
+ # `command_name(SUB_COMMAND) <command_name(SUB_COMMAND)>`
+ # so the XRefRole `fix_parens` option does not add more `()`.
+ m = CMakeXRefRole._re_sub.match(text)
+ if m:
text = f'{text} <{text}>'
elif typ == 'cmake:genex':
m = CMakeXRefRole._re_genex.match(text)