I have a package:
foo.py has a class Foo. In __init__.py I import class Foo
The value of the __module__
attribute is the name of the module in which a class/function/method was defined (see https://docs.python.org/2.7/reference/datamodel.html). The attribute is writable so it can be redefined in __init__.py:
Foo.__module__ = "foo"
Now if you use .. automodule:: foo
, the qualified name of the Foo
class will be shown as foo.Foo
in the generated module documentation.
As an alternative to __module__
-fiddling, you can use autoclass
instead of automodule
.
.. autoclass:: foo.Foo
will produce the wanted output.