我在包含但似乎没有任何效果的rst
文件上运行 Sphinx。automodule
以下是详细信息:我有一个 Python 项目,其中agent.py
包含一个包含类的文件Agent
。我还有一个子目录,里面apidoc
有一个文件agent.rst
(由 生成sphinx-apidoc
):
agent module
============
.. automodule:: agent
:members:
:undoc-members:
:show-inheritance:
sphinx-build -b html apidoc apidoc/_build
我以项目目录作为当前工作目录运行 sphinx 。
为了确保找到 Python 文件,我在 中包含以下内容apidoc/conf.py
:
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
它运行没有错误,但是当我打开生成的 HTML 文件时,它只显示“代理模块”并且一切都是空白的。为什么不显示班级Agent
及其成员?
更新:原来的问题很可能是我没有包含sphinx.ext.autodoc
在conf.py
. 不过,既然我这样做了,我会收到如下警告:
WARNING: invalid signature for automodule ('My Project.agent') WARNING: don't know which module to import for autodocumenting 'My Project.agent' (try placing a "module" or "currentmodule" directive in the document, or giving an explicit module name) WARNING: autodoc: failed to import module 'agent'; the following exception was raised: No module named 'agent'