diff --git a/CHANGES b/CHANGES index 93138d6bf..b8ebb6960 100644 --- a/CHANGES +++ b/CHANGES @@ -60,6 +60,13 @@ Release 1.1 (in development) Release 1.0.7 (in development) ============================== +* #568: Fix lookup of class attribute documentation on descriptors + so that comment documentation now works. + +* Fix traceback with ``only`` directives preceded by targets. + +* Fix tracebacks occurring for duplicate C++ domain objects. + Release 1.0.6 (Jan 04, 2011) ============================ diff --git a/EXAMPLES b/EXAMPLES index 06c558d1c..11e144c17 100644 --- a/EXAMPLES +++ b/EXAMPLES @@ -28,6 +28,8 @@ Documentation using the default theme * Heapkeeper: http://heapkeeper.org/ * Hedge: http://documen.tician.de/hedge/ * Kaa: http://doc.freevo.org/api/kaa/ +* Leo: http://webpages.charter.net/edreamleo/front.html +* Lino: http://lino.saffre-rumma.ee/ * MeshPy: http://documen.tician.de/meshpy/ * mpmath: http://mpmath.googlecode.com/svn/trunk/doc/build/index.html * OpenEXR: http://excamera.com/articles/26/doc/index.html @@ -90,6 +92,7 @@ Documentation using the sphinxdoc theme * MyHDL: http://www.myhdl.org/doc/0.6/ * NetworkX: http://networkx.lanl.gov/ * Pweave: http://mpastell.com/pweave/ +* Pyre: http://docs.danse.us/pyre/sphinx/ * Pysparse: http://pysparse.sourceforge.net/ * PyTango: http://www.tango-controls.org/static/PyTango/latest/doc/html/index.html diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index 1e932f316..e712e01e2 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -165,7 +165,7 @@ class DefExpr(object): return unicode(self).encode('utf-8') def __repr__(self): - return '' % self + return '<%s %s>' % (self.__class__.__name__, self) class PrimaryDefExpr(DefExpr): @@ -822,13 +822,14 @@ class CPPObject(ObjectDescription): def add_target_and_index(self, sigobj, sig, signode): theid = sigobj.get_id() name = unicode(sigobj.name) - signode['names'].append(theid) - signode['ids'].append(theid) - signode['first'] = (not self.names) - self.state.document.note_explicit_target(signode) + if theid not in self.state.document.ids: + signode['names'].append(theid) + signode['ids'].append(theid) + signode['first'] = (not self.names) + self.state.document.note_explicit_target(signode) - self.env.domaindata['cpp']['objects'].setdefault(name, - (self.env.docname, self.objtype, theid)) + self.env.domaindata['cpp']['objects'].setdefault(name, + (self.env.docname, self.objtype, theid)) indextext = self.get_index_text(name) if indextext: diff --git a/sphinx/environment.py b/sphinx/environment.py index 0ea2cbcd6..d47562cd7 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -1409,7 +1409,9 @@ class BuildEnvironment: if ret: node.replace_self(node.children) else: - node.replace_self([]) + # replacing by [] would result in an "Losing ids" exception + # if there is a target node before the only node + node.replace_self(nodes.comment()) # allow custom references to be resolved builder.app.emit('doctree-resolved', doctree, fromdocname) diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 213082795..a026ea908 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -1142,6 +1142,10 @@ class AttributeDocumenter(ClassLevelDocumenter): def document_members(self, all_members=False): pass + def get_real_modname(self): + return self.get_attr(self.parent or self.object, '__module__', None) \ + or self.modname + class InstanceAttributeDocumenter(AttributeDocumenter): """ diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index c4f71f45b..98dc0ee86 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -102,8 +102,10 @@ class ExtBabel(Babel): return '\\shorthandoff{"}' return '' - _ISO639_TO_BABEL = Babel._ISO639_TO_BABEL.copy() - _ISO639_TO_BABEL['sl'] = 'slovene' +# in latest trunk, the attribute is called Babel.language_codes and already +# includes Slovene +if hasattr(Babel, '_ISO639_TO_BABEL'): + Babel._ISO639_TO_BABEL['sl'] = 'slovene' class Table(object): diff --git a/tests/root/objects.txt b/tests/root/objects.txt index 0b71761e4..51ecee911 100644 --- a/tests/root/objects.txt +++ b/tests/root/objects.txt @@ -161,3 +161,14 @@ User markup Referencing :userdescrole:`myobj`. + + +CPP domain +========== + +.. cpp:class:: n::Array + + .. cpp:function:: T& operator[]( unsigned j ) + + .. cpp:function:: const T& operator[]( unsigned j ) const + diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 949ba9d45..8f9025e68 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -17,6 +17,7 @@ from docutils.statemachine import ViewList from sphinx.ext.autodoc import AutoDirective, add_documenter, \ ModuleLevelDocumenter, FunctionDocumenter, cut_lines, between, ALL +from StringIO import StringIO def setup_module(): global app, lid, options, directive @@ -418,6 +419,7 @@ def test_generate(): ('attribute', 'test_autodoc.Class.attr'), ('attribute', 'test_autodoc.Class.docattr'), ('attribute', 'test_autodoc.Class.udocattr'), + ('attribute', 'test_autodoc.Class.mdocattr'), ('attribute', 'test_autodoc.Class.inst_attr_comment'), ('attribute', 'test_autodoc.Class.inst_attr_string') ]) @@ -486,11 +488,19 @@ def test_generate(): ' .. py:attribute:: Class.prop', ' .. py:attribute:: Class.docattr', ' .. py:attribute:: Class.udocattr', + ' .. py:attribute:: Class.mdocattr', ' .. py:attribute:: Class.inst_attr_comment', ' .. py:attribute:: Class.inst_attr_string', ' .. py:method:: Class.inheritedmeth()', ], 'class', 'Class', member_order='bysource', all_members=True) + del directive.env.temp_data['py:module'] + + # test attribute initialized to class instance from other module + directive.env.temp_data['autodoc:class'] = 'test_autodoc.Class' + assert_result_contains(u' should be documented as well - s\xfc\xdf', + 'attribute', 'mdocattr') + del directive.env.temp_data['autodoc:class'] # test autodoc_docstring_signature assert_result_contains( @@ -561,6 +571,10 @@ class Class(Base): udocattr = 'quux' u"""should be documented as well - süß""" + # initialized to any class imported from another module + mdocattr = StringIO() + """should be documented as well - süß""" + def __init__(self, arg): #: a documented instance attribute self.inst_attr_comment = None