From 611d5274de677a42bdf744c48f0e4a29ea1bb1cd Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Sat, 26 Jan 2019 16:48:57 +1100 Subject: Sphinx: Add limited support for nested variables in docs This is needed to allow example code to contain content like `${some_${foo}_bar}`. --- Utilities/Sphinx/cmake.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Utilities/Sphinx') diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py index 882cdc1b73..d903dbe39b 100644 --- a/Utilities/Sphinx/cmake.py +++ b/Utilities/Sphinx/cmake.py @@ -21,6 +21,8 @@ from pygments.lexer import bygroups # - Unix paths are recognized by '/'; support for Windows paths may be added if needed # - (\\.) allows for \-escapes (used in manual/cmake-language.7) # - $<..$<..$>..> nested occurence in cmake-buildsystem +# - Nested variable evaluations are only supported in a limited capacity. Only +# one level of nesting is supported and at most one nested variable can be present. CMakeLexer.tokens["root"] = [ (r'\b(\w+)([ \t]*)(\()', bygroups(Name.Function, Text, Name.Function), '#push'), # fctn( @@ -34,7 +36,8 @@ CMakeLexer.tokens["root"] = [ (r'[<>]=', Punctuation), # used in FindPkgConfig.cmake (r'\$<', Operator, '#push'), # $<...> (r'<[^<|]+?>(\w*\.\.\.)?', Name.Variable), # - (r'(\$\w*\{)(.+?)(\})', bygroups(Operator, Name.Tag, Operator)), # ${..} $ENV{..} + (r'(\$\w*\{)([^\}\$]*)?(?:(\$\w*\{)([^\}]+?)(\}))?([^\}]*?)(\})', # ${..} $ENV{..}, possibly nested + bygroups(Operator, Name.Tag, Operator, Name.Tag, Operator, Name.Tag, Operator)), (r'([A-Z]+\{)(.+?)(\})', bygroups(Operator, Name.Tag, Operator)), # DATA{ ...} (r'[a-z]+(@|(://))((\\.)|[\w.+-:/\\])+', Name.Attribute), # URL, git@, ... (r'/\w[\w\.\+-/\\]*', Name.Attribute), # absolute path -- cgit v1.2.1