Reputation: 5591
I'm using sphinx to create some documentation for a package I'm creating. The documentation generates correctly, however it also creates documentation for imports. Is it possible to configure the automodule to only create documentation for functions present in the module specified (and not the imported modules)?
EDIT
This only occurs when doing the following import: from pylab import *
In the rst file I have:
.. automodule:: name.subname
:members:
mzjn pointed out that this question was already asked: Documenting files with "from x import *"
The answer is to change how pylab is imported:
import pylab
from pylab import *
for k,v in pylab.__dict__.iteritems():
if hasattr(v,'__module__'):
if v.__module__ is None:
locals()[k].__module__ = 'pylab'
Upvotes: 4
Views: 1724
Reputation: 13779
For modules,
__all__
will be respected when looking for members; the order of the members will also be the order in__all__
.
__all__
is a good way for a module to declare what it actually wants to be its public namespace. You can also put a comma separated list of members after :members:
in the Sphinx configuration but __all__
is also useful for imports and other tools.
Upvotes: 3