Include specific special-methods in sphinx

前端 未结 5 2088
南旧
南旧 2021-02-12 15:43

I have a bunch of classes which use \"special-methods\":

class Foo(object):
   \"Foo docstring\"

   attr1 = \"Attribute!\" #: first attribute
   attr2 = \"Anoth         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-12 15:58

    Since Sphinx 1.8, you can use autodoc_default_options in conf.py. Example:

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

    Setting None or True to the value is equivalent to giving only the option name to the directives.

    Note that you can give several values in one string: '__init__,__call__'.

提交回复
热议问题