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
Sphinx uses the __name__
and __module__
members of the class, and the __module__
member of the owner of the class to figure out if it is an alias or the real thing. You can trick Sphinx in thinking that your imported class is the real one by setting these members explicitly.
from a.b.c.d import _Foo as Foo
Foo.__module__ = __name__
Foo.__name__ = 'Foo'
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 '''