summaryrefslogtreecommitdiff
path: root/sphinx/domains/cpp.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-09-23 22:03:34 +0200
committerGeorg Brandl <georg@python.org>2011-09-23 22:03:34 +0200
commitbbe5c12d561a81f6be1887448e247ee099737498 (patch)
treed681b62116946c42c6211ca110d0c932bdb9f9ee /sphinx/domains/cpp.py
parenteccfd85c6cbbb20e6afeeb37410a06acdca32205 (diff)
parenta1330a8413aa1fc31a06aa82b2d65807801f7b51 (diff)
downloadsphinx-bbe5c12d561a81f6be1887448e247ee099737498.tar.gz
Merge with 1.0
Diffstat (limited to 'sphinx/domains/cpp.py')
-rw-r--r--sphinx/domains/cpp.py37
1 files changed, 27 insertions, 10 deletions
diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py
index 3349e32c..7a4e479a 100644
--- a/sphinx/domains/cpp.py
+++ b/sphinx/domains/cpp.py
@@ -21,6 +21,7 @@ from sphinx.domains import Domain, ObjType
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')
@@ -111,7 +112,7 @@ class DefinitionError(Exception):
return self.description
def __str__(self):
- return unicode(self.encode('utf-8'))
+ return unicode(self).encode('utf-8')
class DefExpr(object):
@@ -133,17 +134,21 @@ class DefExpr(object):
def __ne__(self, other):
return not self.__eq__(other)
+ __hash__ = None
+
def clone(self):
- """Close a definition expression node"""
+ """Clone a definition expression node."""
return deepcopy(self)
def get_id(self):
- """Returns the id for the node"""
+ """Return the id for the node."""
return u''
def get_name(self):
- """Returns the name. Returns either `None` or a node with
- a name you might call :meth:`split_owner` on.
+ """Return the name.
+
+ Returns either `None` or a node with a name you might call
+ :meth:`split_owner` on.
"""
return None
@@ -156,7 +161,7 @@ class DefExpr(object):
return None, self
def prefix(self, prefix):
- """Prefixes a name node (a node returned by :meth:`get_name`)."""
+ """Prefix a name node (a node returned by :meth:`get_name`)."""
raise NotImplementedError()
def __str__(self):
@@ -891,6 +896,17 @@ class DefinitionParser(object):
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)
@@ -939,7 +955,7 @@ class CPPObject(ObjectDescription):
indextext = self.get_index_text(name)
if indextext:
- self.indexnode['entries'].append(('single', indextext, theid, name))
+ self.indexnode['entries'].append(('single', indextext, theid, ''))
def before_content(self):
lastname = self.names and self.names[-1]
@@ -1091,8 +1107,9 @@ class CPPFunctionObject(CPPObject):
class CPPCurrentNamespace(Directive):
- """This directive is just to tell Sphinx that we're documenting
- stuff in namespace foo.
+ """
+ This directive is just to tell Sphinx that we're documenting stuff in
+ namespace foo.
"""
has_content = False
@@ -1189,7 +1206,7 @@ class CPPDomain(Domain):
env.warn_node('unparseable C++ definition: %r' % target, node)
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: