gpt4 book ai didi

python - toctree嵌套下拉

转载 作者:行者123 更新时间:2023-11-28 19:48:03 25 4
gpt4 key购买 nike

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

.. toctree::
:maxdepth: 2

cat
dog
moose

我希望嵌套我的 toctree 的内容,类似于它的完成方式 here使用“api 文档”:

enter image description here

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

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

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

最佳答案

侧边栏中目录树的这种行为是阅读文档主题 (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

关于python - toctree嵌套下拉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36925871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com