python - Exclude inherited class methods in sphinx autosummary - Stack Overflow

admin2025-04-26  7

I have a Python package and want to generate the API documentation with the autosummary extension of sphinx.

The problem I am running into is that my main package class inherits from PyTorch's nn.Module, and when running autosummary on my package, it tries to document all the methods in nn.Module, which I don' want.

Is there a way to make autosummary ignore these inherited methods?

I am also using my autosummary call is as follows:

.. autosummary::
    :toctree: generated/
    :recursive:

    my_package

My problematic class is in the module my_package.model.MyClass.

I have tried playing with the autodoc_default_options:

autodoc_default_options = {
    'members': True,
    'undoc-members': False,
    'private-members': False,
    'special-members': False,
    'inherited-members': False,
    'show-inheritance': True,
    'module-first': True,
}

But this didn't work.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745674432a313508.html

最新回复(0)