我的index.rst中有一个toctree看起来像这样:
.. toctree::
:maxdepth: 2
cat
dog
moose
我希望将我的toctree的内容类似于使用' api文档'
完成here的方式。所以最终做出类似的事情:
.. toctree::
:maxdepth: 2
:dropdown Animals
cat
dog
moose
但我似乎无法在文档中找到任何可以做到这一点的内容。
答案 0 :(得分:9)
侧边栏中toctree的这种行为是阅读文档主题(https://github.com/snide/sphinx_rtd_theme)的一项功能
使用pip install sphinx-rtd-theme
主题有选项collapse_navigation
,用于控制是否在导航到文档的其他部分时自动折叠树。
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"collapse_navigation" : False
}
indexr.rst:
#################
Title
#################
Animals
=======
.. toctree::
:maxdepth: 2
animals/index
Flowers
=======
.. toctree::
:maxdepth: 2
flowers/index
动物/ index.rst:
####################
Animals
####################
.. toctree::
:maxdepth: 2
cat
dog
moose