5

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:

enter image description here

mzjn
  • 48,958
  • 13
  • 128
  • 248
OneRaynyDay
  • 3,658
  • 2
  • 23
  • 56

1 Answers1

0

Just change Attributes: to Args:.

EntangledLoops
  • 1,951
  • 1
  • 23
  • 36