我有一个包含index.rst的狮身人面像项目,其中包括:maxdepth: 2。问题是,我希望将1部分的深度缩小到release部分,这样它就不会在主TOC中包含发行说明列表(列表太长)。
似乎可以使用doctree-resolved事件处理程序修改TOC列表,但我不知道如何在事件处理程序中修改TOC树:
from sphinx import addnodes
def setup(app):
def update_toctree(app, doctree, docname):
if docname != 'index':
return
node = doctree.traverse(addnodes.toctree)[0]
toc = app.env.resolve_toctree(docname, app.builder, node)
# do something with "toc" here
app.connect('doctree-resolved', update_toctree)发布于 2015-11-27 09:16:01
我找到了一个低科技的解决方案:用CSS隐藏上一项的子项目。
div.toctree-wrapper > ul > li:last-child > ul {
display: none;
}发布于 2015-11-13 15:19:56
也许不是一个理想的解决方案,但在同一页面上使用多个toctree条目之前,我已经做了类似的事情,比如:
####################
Presto Documentation
####################
.. toctree::
:maxdepth: 2
overview
installation
.. toctree::
:maxdepth: 1
release这并不理想,因为大多数主题都会在树之间添加额外的填充,但在我的例子中,这比为某些页面拥有大量嵌套项列表要好得多。
https://stackoverflow.com/questions/33637299
复制相似问题