All other types (classes, properties, methods, etc) work fine but when autosummary gets to instance attributes it raises "WARNING: failed to import AClass.a
" error. The strange thing is the table is drawn with link to the autodoc code docs below but doc summary column is empty.
Does anyone have this working, or have any ideas what might be wrong?
Shows the table with link but no docs:
Shows that autodoc is working (the link above wouldn't be possible without it):
I've also tried other forms of documentation, such as the #: ...
style, etc. All the same result. Again, everything else in the same module works. I DO see docs in autosummary tables for methods etc.
Example class:
class AClass(object):
def __init__(self):
self.a = 10
"""
An example instance attribute
:type: int
"""
Example ReST:
.. autosummary::
AClass.a
I'm using Sphinx 1.2.3
Unfortunately, autosummary
simply doesn't support this. The bit of code that matters is in sphinx.ext.autosummary.__init__.AutoSummary.get_items
which is essentially:
for name in names:
# <snip>
try:
real_name, obj, parent, modname = import_by_name(name, prefixes=prefixes)
except ImportError:
self.warn('failed to import %s' % name)
items.append((name, '', '', name))
continue
name
is the thing under the autosummary
directive you want to make a summary for, and so in your case is "AClass.a"
. However, since instance attributes are not importable, and import_by_name
attempts to import the name, this fails. I don't know why the implementers did it like this but there we go.
It should be possible to fix this though, if you have time and inclination! I have opened an issue to track it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With