python - 构建 Sphinx 文档

标签 python python-sphinx

我已经开始使用 Sphinx 记录一个 Python 项目。这是我第一次使用它 - 我习惯于使用类似 JavaDoc 语法的工具,但我有一些疑问。

因为我希望文档出现在代码附近,所以我使用了 .. automodule::.. autoclass::.. automethod:: 指令。所以我的文档结构如下:index.rst 包含 TOC 和

.. automodule:: my_main_package

然后顶层__init__.py包含如下指令

.. automodule:: some_subpackage

对于每个子包等等。最后每个模块都包含指令

.. autoclass:: some_class
    :members:

对于模块中的每个类。

这大部分都有效,但我得到的是单页文档,使用起来有点奇怪。

How should I organize my documentation in order to obtain a tree of hyperlinked files? That is, the main package should contain its own documentation and links to each of its subpackages and so on, until each module has its own page.

最佳答案

我找到了这个 autopackage script来自评论 here .它根据您的包的结构生成必要的 .rst 文件。

旁注:我仍然觉得我遗漏了一些东西,因为我无法相信像 Sphinx 这样以最先进的 Python 文档记录工具而著称的工具会缺少执行基本 API 文档记录的功能。因此,在接受我自己的回答之前,我会将问题搁置一段时间。

关于python - 构建 Sphinx 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5319210/

相关文章:

python - 打包经过训练的神经网络的模型权重,使其可用于迁移学习

markup - 如何在 reStructuredText 中创建嵌套列表?

python - Sphinx 不显示泛型类的类实例化参数(即参数类型)

python - 将项目从模型导出到 CSV Django/Python

python - 收集两列数据

python-sphinx - 用 reStructuredText (Sphinx) 替换文件名?

python-sphinx - 使用 intersphinx 进行内部文档

python-sphinx - 如何在 Sphinx 中创建没有标题的盒装文本?

带有 __main__ 的 cli 脚本的 python 实践

python - 泡沫错误 : BadStatusLine in httplib