toctree嵌套下拉

Apa*_*ear 2 python python-sphinx

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

.. toctree::
   :maxdepth: 2

   cat
   dog
   moose
Run Code Online (Sandbox Code Playgroud)

我希望使用'api documentation' 来嵌套我的toctree的内容,类似于这里的内容:

在此输入图像描述

所以最终做出类似的事情:

.. toctree::
   :maxdepth: 2
   :dropdown Animals
     cat
     dog
     moose
Run Code Online (Sandbox Code Playgroud)

但我似乎无法在文档中找到任何可以做到这一点的内容.

P.G*_*.G. 11

侧边栏中toctree的这种行为是Read the Docs主题的一个特性(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
}
Run Code Online (Sandbox Code Playgroud)

indexr.rst:

#################
  Title
#################

Animals
=======

.. toctree::
   :maxdepth: 2

    animals/index

Flowers
=======

.. toctree::
   :maxdepth: 2

    flowers/index
Run Code Online (Sandbox Code Playgroud)

动物/ index.rst:

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

.. toctree::
   :maxdepth: 2

   cat
   dog
   moose
Run Code Online (Sandbox Code Playgroud)

  • 感谢您的回答,但我认为您错误地识别了我的问题,我想知道如何编写 toctree 规则以实际制作类似于示例中的下拉列表。`:dropdown Animals` 命令不正确。我想设置下拉到真实文档页面的任意组部分 (2认同)