如何在Sphinx中遍历文档的每个部分名称?
(doctils的文档在哪里?在Sphinx Application API之外找到有用的东西是非常困难的;即使查看source code for docutils/nodes.py也没有多大帮助。)
答案 0 :(得分:3)
最后通过反复试验找出答案:/
import docutils
def doctree_resolved(app, doctree, docname):
for section in doctree.traverse(docutils.nodes.section):
title = section.next_node(docutils.nodes.Titular)
if title:
print title.astext()
def setup(app):
app.connect('doctree-resolved', doctree_resolved)