ppasler ppasler - 29 days ago 10
Python Question

Can I remove the "src" package from python doc generated with sphinx?

I have a python project and a structure like this

project
|-- doc
|-- src
|-- mod_1.py
| |-- Class1
|-- package1
|-- mod_2.py
|-- Class2


I used
sphinx-apidoc
to create my documentation and the path to my submodules look like this

src.mod1
src.package2.mod2


Now I wonder, if there is a way to remove the
src
prefix?
To make the path look like this

mod1
package2.mod2

Answer

After raising an issue at GitHub sphinx #3113, shimizukawa came up with a solution:

  • Remove __init__.py from src folder
  • Set pythonpath to /../src instead of /../ in the conf.py
Comments