1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-19 02:17:27 +08:00

Utilities/Sphinx: Add role and directive for 'envvar' in CMake domain

This enables cross-reference syntax for CMake environment variables:

    :envvar:`SOMEVAR`

and definition of CMake environment variables via a directive:

    .. envvar:: SOMEVAR

It also adds environment variables defined by the directive and by
`Help/envvar/SOMEVAR.rst` documents to the index.

This `envvar` role and directive is defined in our `cmake` domain
and overrides the equivalent `envvar` role and directive provided
by Sphinx in its default domain.  This is okay because we build
CMake documents in the `cmakd` domain.

This follows up the work from commit v3.10.0-rc1~43^2 (Help: Document
CMake's environment variables, 2017-09-01) that originally added
`envvar` documentation.
This commit is contained in:
Brad King
2018-04-19 08:50:06 -04:00
parent 7e532abc78
commit 8acf46caf1
2 changed files with 5 additions and 0 deletions

View File

@@ -144,6 +144,7 @@ class _cmake_index_entry:
_cmake_index_objs = { _cmake_index_objs = {
'command': _cmake_index_entry('command'), 'command': _cmake_index_entry('command'),
'envvar': _cmake_index_entry('envvar'),
'generator': _cmake_index_entry('generator'), 'generator': _cmake_index_entry('generator'),
'manual': _cmake_index_entry('manual'), 'manual': _cmake_index_entry('manual'),
'module': _cmake_index_entry('module'), 'module': _cmake_index_entry('module'),
@@ -324,6 +325,7 @@ class CMakeDomain(Domain):
label = 'CMake' label = 'CMake'
object_types = { object_types = {
'command': ObjType('command', 'command'), 'command': ObjType('command', 'command'),
'envvar': ObjType('envvar', 'envvar'),
'generator': ObjType('generator', 'generator'), 'generator': ObjType('generator', 'generator'),
'variable': ObjType('variable', 'variable'), 'variable': ObjType('variable', 'variable'),
'module': ObjType('module', 'module'), 'module': ObjType('module', 'module'),
@@ -339,6 +341,7 @@ class CMakeDomain(Domain):
} }
directives = { directives = {
'command': CMakeObject, 'command': CMakeObject,
'envvar': CMakeObject,
'variable': CMakeObject, 'variable': CMakeObject,
# Other object types cannot be created except by the CMakeTransform # Other object types cannot be created except by the CMakeTransform
# 'generator': CMakeObject, # 'generator': CMakeObject,
@@ -355,6 +358,7 @@ class CMakeDomain(Domain):
} }
roles = { roles = {
'command': CMakeXRefRole(fix_parens = True, lowercase = True), 'command': CMakeXRefRole(fix_parens = True, lowercase = True),
'envvar': CMakeXRefRole(),
'generator': CMakeXRefRole(), 'generator': CMakeXRefRole(),
'variable': CMakeXRefRole(), 'variable': CMakeXRefRole(),
'module': CMakeXRefRole(), 'module': CMakeXRefRole(),

View File

@@ -21,6 +21,7 @@ newlines = []
for line in lines: for line in lines:
mapping = (("command", "command"), mapping = (("command", "command"),
("envvar", "envvar"),
("variable", "variable"), ("variable", "variable"),
("generator", "generator"), ("generator", "generator"),
("target property", "prop_tgt"), ("target property", "prop_tgt"),