Add convenience directives and roles to C++ domain

Add directive `cpp:var` and roles `cpp:var` and `cpp:any`.
Fixes sphinx-doc/sphinx#1577, fixes sphinx-doc/sphinx#1744.
This commit is contained in:
Jakob Lykke Andersen 2015-02-26 21:44:46 +01:00
parent 8a273d139b
commit b1775cbf8c
3 changed files with 18 additions and 3 deletions

View File

@ -7,6 +7,13 @@ Incompatible changes
* Roles ``ref``, ``term`` and ``menusel`` now don't generate :durole:`emphasis`
nodes anymore. If you want to keep italic style, adapt your stylesheet.
Features added
--------------
* Add convenience directives and roles to the C++ domain:
directive `var` as alias for `member`, role `var`as alias for `member`,
and role `any` for cross-reference to any C++ declaraction. #1577, #1744
Release 1.3b3 (released Feb 24, 2015)
=====================================

View File

@ -557,7 +557,8 @@ a visibility statement (``public``, ``private`` or ``protected``).
Describe a copy constructor with default implementation.
.. rst:directive:: .. cpp:member:: variable or member declaration
.. rst:directive:: .. cpp:member:: (member-)variable declaration
.. cpp:var:: (member-)variable declaration
Describe a varible or member variable, e.g.,::
@ -565,6 +566,8 @@ a visibility statement (``public``, ``private`` or ``protected``).
.. cpp:member:: std::string theclass::name[N][M]
.. cpp:member:: int a = 42
.. rst:directive:: .. cpp:type:: typedef-like declaration
.. cpp:type:: name
@ -585,7 +588,7 @@ a visibility statement (``public``, ``private`` or ``protected``).
Describe a (scoped) enum, possibly with the underlying type specified.
Any enumerators declared inside an unscoped enum will be declared both in the enum scope
and in the parent scope.
Examples:
Examples::
.. cpp:enum:: MyEnum
@ -626,9 +629,11 @@ a visibility statement (``public``, ``private`` or ``protected``).
These roles link to the given object types:
.. rst:role:: cpp:class
.. rst:role:: cpp:any
cpp:class
cpp:func
cpp:member
cpp:var
cpp:type
cpp:enum
cpp:enumerator

View File

@ -2372,6 +2372,7 @@ class CPPDomain(Domain):
'class': CPPClassObject,
'function': CPPFunctionObject,
'member': CPPMemberObject,
'var': CPPMemberObject,
'type': CPPTypeObject,
'enum': CPPEnumObject,
'enum-struct': CPPEnumObject,
@ -2380,9 +2381,11 @@ class CPPDomain(Domain):
'namespace': CPPNamespaceObject
}
roles = {
'any': CPPXRefRole(),
'class': CPPXRefRole(),
'func': CPPXRefRole(fix_parens=True),
'member': CPPXRefRole(),
'var': CPPXRefRole(),
'type': CPPXRefRole(),
'enum': CPPXRefRole(),
'enumerator': CPPXRefRole()