Overriding Sphinx autodoc “Alias of” for import of private class?

前端 未结 2 807
春和景丽
春和景丽 2021-02-18 22:46

I have a Python package that I am attempting to document with sphinx-autodoc. My python package has an __init__.py file that imports a class out from a submodule to

2条回答
  •  面向向阳花
    2021-02-18 23:29

    Using the members directive you can show all members except those that start with '_'. You can leave _Foo undocumented in a.b.c.d and document it as Foo in a.b.c. I would import _Foo as from a.b.c.d import _Foo and then add whatever documentation like:

    Foo = _Foo
    ''' blah blah blah '''
    

    If, for some reason, you don't want _Foo in a.b.c's namespace, then you can also do:

    from a.b.c.d import _Foo as Foo
    Foo = Foo
    ''' blah blah blah '''
    

提交回复
热议问题