Reputation: 3968
As this post describes, autodoc will eagerly add the class variables to the documentation even if napoleon adds the fields as documentation in:
from dataclasses import dataclass
@dataclass
class Foo():
"""Some class
Attributes:
a: foo
b: bar
"""
a: str
b: int
def c(self) -> int:
"""Here's a doc'd function
"""
return 3
I want to explicitly tell autodoc to not document any class variables (which is also instance variables in the case of dataclasses) - I only want autodoc to show declared functions for a given class and let napoleon handle the class/instance variables for all classes it finds. Is this possible without :exclude-members:
for every class (which is a huge hassle)?
I already tried:
autodoc_default_options = {
'members': True,
'undoc-members': False,
}
in my conf.py
and this in the .rst
file:
.. automodule:: some.module
:members:
:show-inheritance:
Which should hide undocumented members but they still show up:
Upvotes: 7
Views: 1740
Reputation: 81
Removing :undoc-members:
directive from the corresponding module did the job for me. This does not have the perfect granularity control but if you dataclasses are in the same module or if you don't care about not documenting other stuff without docstrings, this should do the job.
Upvotes: 0