MCPcopy Create free account
hub / github.com/Kitware/CMake / CMakeReferenceRole

Class CMakeReferenceRole

Utilities/Sphinx/cmake.py:505–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

503
504
505class CMakeReferenceRole:
506 # See sphinx.util.nodes.explicit_title_re; \x00 escapes '<'.
507 _re = re.compile(r'^(.+?)(\s*)(?<!\x00)<(.*?)>$', re.DOTALL)
508
509 @staticmethod
510 def _escape_angle_brackets(text: str) -> str:
511 # CMake cross-reference targets frequently contain '<' so escape
512 # any explicit `<target>` with '<' not preceded by whitespace.
513 while True:
514 m = CMakeReferenceRole._re.match(text)
515 if m and len(m.group(2)) == 0:
516 text = f'{m.group(1)}\x00<{m.group(3)}>'
517 else:
518 break
519 return text
520
521 def __class_getitem__(cls, parent: Any):
522 class Class(parent):
523 def __call__(self, name: str, rawtext: str, text: str,
524 *args, **kwargs
525 ) -> Tuple[List[Node], List[system_message]]:
526 text = CMakeReferenceRole._escape_angle_brackets(text)
527 return super().__call__(name, rawtext, text, *args, **kwargs)
528 return Class
529
530
531class CMakeCRefRole(CMakeReferenceRole[ReferenceRole]):

Callers

nothing calls this directly

Calls 1

compileMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…