toctree嵌套下拉

toctree nested drop down

我的 index.rst 中有一个 toctree,看起来像这样:

.. toctree::
   :maxdepth: 2

   cat
   dog
   moose

我希望嵌套我的 toctree 的内容,类似于 here 和 'api documentation' 的完成方式:

所以最终做出类似的东西:

.. toctree::
   :maxdepth: 2
   :dropdown Animals
     cat
     dog
     moose

但我似乎无法在文档中找到执行此操作的任何内容。

侧边栏中 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

animals/index.第一:

####################
  Animals
####################

.. toctree::
   :maxdepth: 2

   cat
   dog
   moose