问题标签 [sphinx-napoleon]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
51 浏览

python - Sphinx autodoc/napoleon 不生成文档字符串

我正在做一个非常简单的示例,但无法使其正常工作。我只有一个文件,simulator.py我在其中添加了 numpy 样式的文档字符串。它不导入任何其他库。它有一个__init__,我可以从 python 解释器中导入它。我的目录结构如下:

我正在使用 sphinx-build 4.0.2。我 pip 安装了 sphinxcontrib-napoleon,即使 sphinx-ext.napoleon 应该包含在 sphinx 的更高版本中。

在我的 conf.py 中,我有

为了制作我的.rst文件,我sphinx-apidoc -f --ext-autodoc -o . ../simulatordocs目录运行。它创建modules.rstsimulator.rst。我在目录树中添加了“模块” index.rst,而“模拟器”在自动构建的目录树中modules.rst

它在每个文件中创建一个标题和一个目录树。没有文档字符串。我读到它只是创建模型来从文档字符串构建 html,所以我运行了make html. 它仅使用目录构建,文档字符串中没有任何内容。可能出了什么问题?path.insert()即使我很确定我所拥有的内容是正确的,我也尝试了该命令的不同变体。我已经尝试移动到主目录,我尝试从我通过搜索此问题的其他解决方案找到的示例文件simulator.py中添加一堆其他随机废话。conf.py没有一个解决方案奏效。