我尝试使用Sphinx(1.5.3)为Python repo创建文档,其结构如下:
main_repo/
├── docs
├── src
| ├── subrepo1
| ├── subrepo2
| └── subrepo3
└── tests
Python代码在src
中被构造成三个不同的Python包。这里subrepo1
只是main_repo
的一部分,但是subrepo2
和{docs
文件夹中:
在conf.py
中,我使用了
sys.path.insert(0, os.path.abspath(os.path.join('path/to/src')))
为了将src
目录的完整路径添加到sys.path
,并且在index.rst
中,我添加了以下指令来为subrepo1
包中的一个类生成文档:
.. toctree::
:maxdepth: 2
:caption: Contents:
.. automodule:: subrepo1.module
.. autoclass:: Class1
:members:
这里module
是包subrepo1
内模块module.py
的名称,Class1
是{
我运行make html
时出现以下错误:
/path/to/src/docs/index.rst:13: WARNING: autodoc: failed to import module u'subrepo1.module'; the module executes module level statement and it might call sys.exit().
/path/to/src/docs/index.rst:15: WARNING: don't know which module to import for autodocumenting u'Class1' (try placing a "module" or "currentmodule" directive in the document, or giving an explicit module name)
我想为所有子模块和子包中的所有类生成文档,包括类构造函数和所有“public”方法和属性,它们位于main_repo
内的这三个子存储库中。在index.rst
中执行此操作的指令是什么?在
目前没有回答
相关问题 更多 >
编程相关推荐