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

 ̄綄美尐妖づ 提交于 2021-01-28 14:37:00

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/36579500/can-i-remove-the-src-package-from-python-doc-generated-with-sphinx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!