How to use Sphinx's autodoc to document a class's __init__(self) method?

后端 未结 5 2015
长情又很酷
长情又很酷 2020-12-04 09:49

Sphinx doesn\'t generate docs for __init__(self) by default. I have tried the following:

.. automodule:: mymodule
    :members:

and

5条回答
  •  日久生厌
    2020-12-04 09:59

    Even though this is an older post, for those who are looking it up as of now, there is also another solution introduced in version 1.8. According to the documentation, You can add the special-member key in the autodoc_default_options to your conf.py.

    Example:

    autodoc_default_options = {
        'members': True,
        'member-order': 'bysource',
        'special-members': '__init__',
        'undoc-members': True,
        'exclude-members': '__weakref__'
    }
    

提交回复
热议问题