From ef62d317e5cd42759dc2212b50d49cd957757a05 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Sat, 2 Oct 2010 00:05:59 -0700 Subject: [PATCH] autodoc's docstring/special-comment detection works for instance attributes too --- doc/ext/autodoc.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/ext/autodoc.rst b/doc/ext/autodoc.rst index a1d9d98fb7..68837a9a98 100644 --- a/doc/ext/autodoc.rst +++ b/doc/ext/autodoc.rst @@ -183,16 +183,23 @@ inserting them into the page source under a suitable :rst:dir:`py:module`, For module data members and class attributes, documentation can either be put into a special-formatted comment *before* the attribute definition, or in a docstring *after* the definition. This means that in the following class - definition, both attributes can be autodocumented:: + definition, all attributes can be autodocumented:: class Foo: """Docstring for class Foo.""" - #: Doc comment for attribute Foo.bar. + #: Doc comment for class attribute Foo.bar. bar = 1 baz = 2 - """Docstring for attribute Foo.baz.""" + """Docstring for class attribute Foo.baz.""" + + def __init__(self): + #: Doc comment for instance attribute qux. + self.qux = 3 + + self.spam = 4 + """Docstring for instance attribute spam.""" .. versionchanged:: 0.6 :rst:dir:`autodata` and :rst:dir:`autoattribute` can now extract docstrings.