我想知道是否有办法扩展index.rst
文件中包含的标题下的所有子部分?
作为一个例子,这是如何:
Section 1
Section 2
Section 3
以下是我希望如何:
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
如果我点击第1部分,它会显示下面的内容,但是如果我点击第2部分,则隐藏第1部分的内容,只显示2。我想在每次进入索引页面时扩展所有2个部分。我尝试添加toctree
和maxdepth
,没有任何作用。
答案 0 :(得分:11)
好吧,我失去了大约3.4M的神经元,试图读取斯芬克斯源代码(它是由一群拉比鲁莽的浣熊写的?!这么多级别的抽象)。
所以:
fulltoc.html:
{{ toctree(collapse=False) }}
(嘿,请注意'崩溃'论点?)
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']}
答案 1 :(得分:0)
如果您使用的是sphinx_rtd_theme,则可以通过更改文件 layout.html 中定义的“ toctree maxdepth”值来更改html页面中侧边栏菜单的最大深度。该文件通常位于目录source/_themes/sphinx_rtd_theme
中。有几种解决方案:
最简单,最快的解决方案:Show deeper toctree in sidebar
您正在使用旧版本的主题。然后,您可以在显示以下内容的行中设置新的“最大深度”值(例如3):
{% set toctree = toctree(maxdepth=3, collapse=False, includehidden=True) %}
您正在使用主题的最新版本。然后,您可能在文件 layout.html 中的这些行:
{% set global_toc = toctree(maxdepth=theme_navigation_depth|int,
collapse=theme_collapse_navigation|tobool,
includehidden=theme_includehidden|tobool,
titles_only=theme_titles_only|tobool) %}
在这种情况下,您可以在theme.conf中定义“ theme_navigation_depth”:
[options]
theme_navigation_depth = 3
更改完成后重新编译...并且不要忘记享受阳光!
答案 2 :(得分:0)
不幸的是,有一个关于这个的开放错误: https://github.com/readthedocs/sphinx_rtd_theme/issues/455