diff options
author | Craig Scott <craig.scott@crascit.com> | 2019-01-26 05:48:57 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2019-01-26 05:49:15 (GMT) |
commit | 611d5274de677a42bdf744c48f0e4a29ea1bb1cd (patch) | |
tree | c035af77b3a244d65388a343620e08b543ce3329 /Utilities/Sphinx/cmake.py | |
parent | 1a07e1b47d2c0a5b19013f359bbdaecfd17387b2 (diff) | |
download | CMake-611d5274de677a42bdf744c48f0e4a29ea1bb1cd.zip CMake-611d5274de677a42bdf744c48f0e4a29ea1bb1cd.tar.gz CMake-611d5274de677a42bdf744c48f0e4a29ea1bb1cd.tar.bz2 |
Sphinx: Add limited support for nested variables in docs
This is needed to allow example code to contain content like
`${some_${foo}_bar}`.
Diffstat (limited to 'Utilities/Sphinx/cmake.py')
-rw-r--r-- | Utilities/Sphinx/cmake.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py index 882cdc1..d903dbe 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), # <expr> - (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 |