我正在做一个非常简单的示例,但无法使其正常工作。我只有一个文件,simulator.py
我在其中添加了 numpy 样式的文档字符串。它不导入任何其他库。它有一个__init__
,我可以从 python 解释器中导入它。我的目录结构如下:
|__ modules
|__ __init__.py
|__ simulator
| |__ simulator.py
|__ docs
|__ Makefile
|__ _static
|__ conf.py
|__ index.rst
|__ modules.rst
|__ _build
|__ _templates
|__ simulator.rst
|__ make.bat
我正在使用 sphinx-build 4.0.2。我 pip 安装了 sphinxcontrib-napoleon,即使 sphinx-ext.napoleon 应该包含在 sphinx 的更高版本中。
在我的 conf.py 中,我有
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
和
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon'
]
为了制作我的.rst
文件,我sphinx-apidoc -f --ext-autodoc -o . ../simulator
从docs
目录运行。它创建modules.rst
和simulator.rst
。我在目录树中添加了“模块” index.rst
,而“模拟器”在自动构建的目录树中modules.rst
。
它在每个文件中创建一个标题和一个目录树。没有文档字符串。我读到它只是创建模型来从文档字符串构建 html,所以我运行了make html
. 它仅使用目录构建,文档字符串中没有任何内容。可能出了什么问题?path.insert()
即使我很确定我所拥有的内容是正确的,我也尝试了该命令的不同变体。我已经尝试移动到主目录,我尝试从我通过搜索此问题的其他解决方案找到的示例文件simulator.py
中添加一堆其他随机废话。conf.py
没有一个解决方案奏效。