在__init __.py中导入的狮身人面像隐藏模块
我的软件包具有类似于以下内容的结构:
├── README.md
├── __init__.py
├── module1
│ └── submodule1.py
│ └── submodule2.py
├── module2
│ ├── __init__.py
│ ├── _hiden_submodule1.py
│ ├── _hiden_submodule2.py
│ └── _hiden_submodule3.py
我设法使用sphinx从docstrings中记录所有结构,并带有自动夏季和递归选项:
.. autosummary::
:toctree: _autosummary
:template: custom-module-template.rst
:recursive:
mymodule
这使我从模块到功能都非常好。
但是,_hiden_submodules*.py
函数被导入到__ init __. py
:
from mymodule.module2._hiden_submodules1 import *
from mymodule.module2._hiden_submodules2 import *
from mymodule.module2._hiden_submodules3 import *
我希望这些函数直接出现在文档中,作为模块的一部分,而不是Module2.hiden_subModules*
的一部分。我该如何实现?
My package has a structure, similar to the following:
├── README.md
├── __init__.py
├── module1
│ └── submodule1.py
│ └── submodule2.py
├── module2
│ ├── __init__.py
│ ├── _hiden_submodule1.py
│ ├── _hiden_submodule2.py
│ └── _hiden_submodule3.py
I have managed to document all of it from the docstrings using sphinx, with the autosummary and recursive option:
.. autosummary::
:toctree: _autosummary
:template: custom-module-template.rst
:recursive:
mymodule
which gives me very nice toctrees from modules to functions.
However, _hiden_submodules*.py
functions are imported into the __init__.py
of module2:
from mymodule.module2._hiden_submodules1 import *
from mymodule.module2._hiden_submodules2 import *
from mymodule.module2._hiden_submodules3 import *
I would like these functions to appear directly in the documentation as being part of module2, and not part of module2.hiden_submodules*
. How can I achieve that ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需
在您的
conf.py
文件中设置。参见在这里。Simply set
in your
conf.py
file. See here.