我有一些基于 Sphinx 的文档,用于我构建的库,我想显示除更改日志之外的所有页面的扩展目录。我通过将更改日志移到第二个 :toctree::
来弄清楚如何做到这一点,但这有一些奇怪的行为。主要是,当我访问页面时,更改日志会显示在不同的项目符号列表中,而当我使用侧边栏导航时,我只能在每个目录树中导航(如果我单击更改日志,我将不会在侧边栏上显示其他部分)。有一个更好的方法吗?
这是我现在所拥有的:
.. toctree::
:maxdepth: 5
getting_started
examples
modules
.. toctree::
:maxdepth: 1
changelog
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
最佳答案
与 Read the Docs模板你可以实现这一点。您还必须操作 _static 目录中的 style.css 文件。只需添加
.rst-content .toctree-wrapper:not(:last-child) ul {
margin-bottom: 0;
}
两个独立的目录树看起来像一个,它们将显示在侧栏中。对于其他 Sphinx 模板,检查呈现的 html 可以引导您找到正确的 css-selector 方向。但我不知道这些模板如何处理侧边栏。
关于python - 不同的 :maxdepth: for specific entries in toctree (Sphinx),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56195758/