C++, make prefixes of type declarations better.

Type declarations are now using the prefixes ``typedef``, ``using``, and ``type``,
depending on the style of declaration.
See also michaeljones/breathe#243 and michaeljones/breathe#242.
This commit is contained in:
Jakob Lykke Andersen 2016-03-30 16:55:02 +09:00
parent dca9e59ea5
commit c6ba3093fe
3 changed files with 33 additions and 3 deletions

View File

@ -13,7 +13,9 @@ Translations
Bugs fixed
----------
- C++, added support for 'extern' and 'thread_local'.
- C++, added support for ``extern`` and ``thread_local``.
- C++, type declarations are now using the prefixes ``typedef``, ``using``, and ``type``,
depending on the style of declaration.
Release 1.4 (released Mar 28, 2016)

View File

@ -629,9 +629,26 @@ a visibility statement (``public``, ``private`` or ``protected``).
A type alias can also be templated::
.. cpp:type:: template<typename T>
.. cpp:type:: template<typename T> \
MyContainer = std::vector<T>
The example are rendered as follows.
.. cpp:type:: std::vector<int> MyList
A typedef-like declaration of a type.
.. cpp:type:: MyContainer::const_iterator
Declaration of a type alias with unspecified type.
.. cpp:type:: MyType = std::unordered_map<int, std::string>
Declaration of a type alias.
.. cpp:type:: template<typename T> \
MyContainer = std::vector<T>
.. rst:directive:: .. cpp:enum:: unscoped enum declaration
.. cpp:enum-struct:: scoped enum declaration

View File

@ -1933,6 +1933,12 @@ class ASTType(ASTBase):
res.append(text_type(self.decl))
return u''.join(res)
def get_type_declaration_prefix(self):
if self.declSpecs.trailingTypeSpec:
return 'typedef'
else:
return 'type'
def describe_signature(self, signode, mode, env, symbol):
_verify_description_mode(mode)
self.declSpecs.describe_signature(signode, 'markType', env, symbol)
@ -1997,6 +2003,9 @@ class ASTTypeUsing(ASTBase):
res.append(text_type(self.type))
return u''.join(res)
def get_type_declaration_prefix(self):
return 'using'
def describe_signature(self, signode, mode, env, symbol):
_verify_description_mode(mode)
self.name.describe_signature(signode, mode, env, symbol=symbol)
@ -2210,7 +2219,9 @@ class ASTDeclaration(ASTBase):
mainDeclNode += addnodes.desc_annotation(self.visibility + " ",
self.visibility + " ")
if self.objectType == 'type':
mainDeclNode += addnodes.desc_annotation('type ', 'type ')
prefix = self.declaration.get_type_declaration_prefix()
prefix += ' '
mainDeclNode += addnodes.desc_annotation(prefix, prefix)
elif self.objectType == 'member':
pass
elif self.objectType == 'function':