Fixed a C++ bug that caused bad references to be generated. This also

adds a note on overloads always ending up on the first version of the
method in case more than one is defined.
This commit is contained in:
Armin Ronacher 2010-05-30 13:51:50 +02:00
parent 35f0b555a4
commit 475c3ba93b
2 changed files with 19 additions and 5 deletions

View File

@ -511,6 +511,15 @@ These roles link to the given object types:
Reference a C++ object. You can give the full signature (and need to, for
overloaded functions.)
.. admonition:: Note on References
It is currently impossible to link to a specific version of an
overloaded method. Currently the C++ domain is the first domain
that has basic support for overloaded methods and until there is more
data for comparison we don't want to select a bad syntax to reference a
specific overload. Currently Sphinx will link to the first overloaded
version of the method / function.
The Standard Domain
-------------------

View File

@ -828,8 +828,13 @@ class CPPObject(ObjectDescription):
signode['ids'].append(theid)
signode['first'] = (not self.names)
self.state.document.note_explicit_target(signode)
self.env.domaindata['cpp']['objects'][name] = \
(self.env.docname, self.objtype)
# XXX: why is objtype function? How to get to func?
typ = self.objtype
if typ == 'function':
typ = 'func'
self.env.domaindata['cpp']['objects'].setdefault(name,
(self.env.docname, typ, theid))
indextext = self.get_index_text(name)
if indextext:
@ -1053,7 +1058,7 @@ class CPPDomain(Domain):
}
def clear_doc(self, docname):
for fullname, (fn, _) in self.data['objects'].items():
for fullname, (fn, _, _) in self.data['objects'].items():
if fn == docname:
del self.data['objects'][fullname]
@ -1066,7 +1071,7 @@ class CPPDomain(Domain):
obj = self.data['objects'][name]
if obj[1] != typ:
return None
return make_refnode(builder, fromdocname, obj[0], expr.get_id(),
return make_refnode(builder, fromdocname, obj[0], obj[2],
contnode, name)
parser = DefinitionParser(target)
@ -1094,5 +1099,5 @@ class CPPDomain(Domain):
return _create_refnode(expr.prefix(parent))
def get_objects(self):
for refname, (docname, type) in self.data['objects'].iteritems():
for refname, (docname, type, theid) in self.data['objects'].iteritems():
yield (refname, refname, type, docname, refname, 1)