0

I am developing a python package with some sub-packages and modules. I have a few modules that are quite large and would like to split them. I will end up having a single class per module in that particular subpackage. To give an example imagine:

package
├── __init__.py
├── subpackage_1
│   ├── __init__.py
│   ├── foo.py
│   └── bar.py
├── subpackage_2
│   ├── __init__.py
│   └── module_x.py
├── module_y.py
└── ..
 

Modules foo and bar have only one class:

foo.py:

class Foo:
   pass

bar.py:

class Bar:
   pass

To access these classes in an easy way without double names, the init file in subpackage_1:

__init__.py:

from .foo import Foo
from .bar import Bar
def __dir__():
   return ['Foo', 'Bar']

While coding, after importing this package, classes can be accessed as: package.subpackage_1.Foo. When I generate my sphinx html documentation with autodoc, these classes show up as package.subpackage_1.foo.Foo.

How can I automatically remove the module name when it is the same as the class name everywhere in my html documentation and show package.subpackage_1.Foo? This would be coherent with how a user uses this library with tab completion.

mzjn
  • 48,958
  • 13
  • 128
  • 248
Worldsheep
  • 163
  • 3

0 Answers0