Georg Brandl committed 689094e

Closes #680: allow doc fields in cpp domain directives.

  • Participants
  • Parent commits 27c5d9f

Comments (0)

Files changed (2)

     multiple terms per definition.
   - #478: Added :rst:dir:`py:decorator` directive to describe decorators.
   - C++ domain now supports array definitions.
+  - C++ domain now supports doc fields (``:param x:`` inside directives).
   - Section headings in :rst:dir:`only` directives are now correctly
   - Added ``emphasize-lines`` option to source code directives.

File sphinx/domains/

 from sphinx.directives import ObjectDescription
 from sphinx.util.nodes import make_refnode
 from sphinx.util.compat import Directive
+from sphinx.util.docfields import Field, GroupedField
 _identifier_re = re.compile(r'(~?\b[a-zA-Z_][a-zA-Z0-9_]*)\b')
 class CPPObject(ObjectDescription):
     """Description of a C++ language object."""
+    doc_field_types = [
+        GroupedField('parameter', label=l_('Parameters'),
+                     names=('param', 'parameter', 'arg', 'argument'),
+                     can_collapse=True),
+        GroupedField('exceptions', label=l_('Throws'), rolename='cpp:class',
+                     names=('throws', 'throw', 'exception'),
+                     can_collapse=True),
+        Field('returnvalue', label=l_('Returns'), has_arg=False,
+              names=('returns', 'return')),
+    ]
     def attach_name(self, node, name):
         owner, name = name.split_owner()
         varname = unicode(name)
             return None
-        parent = node['cpp:parent']
+        parent = node.get('cpp:parent', None)
         rv = _create_refnode(expr)
         if rv is not None or parent is None: