toctree嵌套下拉

时间:2016-04-28 21:34:01

标签: python python-sphinx

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

.. toctree::
   :maxdepth: 2

   cat
   dog
   moose

我希望将我的toctree的内容类似于使用' api文档'

完成here的方式。

enter image description here

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

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

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

1 个答案:

答案 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
相关问题