最后,我找到了实现自己想要的方法。这是操作方法:
- 创建一个python脚本 (我们称之为
generate-includes.py
),该 脚本 将生成 reStructuredText 并将其保存在myrst.inc
文件中。(在我的示例中,这将是脚本加载和解析YAML,但这无关紧要)。 确保此文件是可执行文件!!! include
在要插入动态生成的文档的位置上, 使用 文档的主.rst文档中 的 伪指令 :.. include:: myrst.inc
修改sphinx Makefile ,以便在构建时生成所需的.inc文件:
myrst.inc:./generate-includes.py
html: myrst.inc
…(other stuff here)通常 使用来 构建文档
make html
。



