The package I am documenting consists of a set of *.py
files, most containing one class with a couple of files being genuine modules with functions defined. I do not need to expose the fact that each class is in a module so I have added suitable from
statements in the __init__.py
file e.g.
from base import Base
so that the user can use the import pkg
command and does not then have to specify the module that contains the class:
import pkg
class MyBase(pkg.Base): # instead of pkg.base.Base ...
...
The problem is that Sphinx insists on documenting the class as pkg.base.Base
. I have tried to set the add_module_names = False
in conf.py
. However this results in Sphinx showing the class as simply Base
instead of pkg.Base
. Additionally this also ruins the documentation of the couple of *.py
files that are modules.
How do I make Sphinx show a class as pkg.Base
?
And how do I set the add_module_names
directive selectively for each *.py
file?