I'm finding conflicting and often dated information so hoping someone can clear this up.
I'd like to document something like this using Sphinx:
class MyClass:
"""
MyClass, which is documented with a docstring at the class level
"""
classVar = None
"""A class var with an initial value and a 1-line doc"""
def __init__(self):
"""
__init__'s docs
"""
instanceVar1 = 10
"""An instance var with an initial val and 1-line doc"""
#: An instance var with an initial val and a doc-comment
instanceVar2 = 10
In my docs, I'd like to see instanceVar1 and its docstring (ideally with its default value, but I'd be happy with just the description). But if I run with an rst file of:
.. automodule:: mymodule.mycode
:members:
I only see the class attributes, not the instance attributes:
Googling gives me conflicting info on what should/shouldn't work. Several older stack overflow chains cite issues with autodocumentation for instance attributes (such as here) but they also refer to it working if you've added docstrings like I've done above. Sphinx docs cite that all attributes can be autodocumented.
Can anyone comment on whether what I'm trying to do should work/it works for them now you/suggestions on what I might have messed up? Thanks.