如何扩展Sphinx中侧边栏toctree上的所有子部分

Joe*_*e D 35 python documentation sidebar python-sphinx

我想知道是否有办法扩展文件中包含的标题下的所有子部分index.rst

举个例子,它是这样的:

Section 1
Section 2
Section 3
Run Code Online (Sandbox Code Playgroud)

以下是我希望如何:

Section 1
  Subsection 1.1
  Subsection 1.2
  Subsection 1.3
Section 2
  Subsection 2.1
  Subsection 2.2
  Subsection 2.3
Section 3
  Subsection 3.1
  Subsection 3.2
  Subsection 3.3
Run Code Online (Sandbox Code Playgroud)

如果我点击第1部分,它会显示下面的内容,但是如果我点击第2部分,则隐藏第1部分的内容,只显示2.我想在每次进入索引页面时扩展所有2个部分.我试过加toctreemaxdepth,没有什么作品.

Ste*_*tin 12

好吧,我失去了大约3.4M神经元试图读取斯芬克斯源代码(它是由一群拉比鲁莽的浣熊写的吗?!这么多级别的抽象).

所以:

  • 制作你自己的狮身人面像主题(使用第三方主题作为基础,非常简单.我使用'可读'主题)
  • 在您拥有theme.conf的目录中,添加一个"fulltoc.html"模板,其中包含一行:

fulltoc.html:

{{ toctree(collapse=False) }}
Run Code Online (Sandbox Code Playgroud)

(嘿,注意'崩溃'的论点?)

  • 在sphinx conf.py中,修改html_sidebars选项以添加模板; 并宣布你的主题

conf.py:

html_theme_path = [customized_readable_theme.get_html_theme_path()]
html_theme = 'customized_readable'
html_sidebars = {'**': ['fulltoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html']}
Run Code Online (Sandbox Code Playgroud)
  • 重建文档