python - 不同的 :maxdepth: for specific entries in toctree (Sphinx)

标签 python python-sphinx toctree

我有一些基于 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/

相关文章:

python-sphinx - 禁用单个 Sphinx 警告消息

python - 在 lambda 中自动元组解包的好的 python3 等价物是什么?

Python XML 解析示例

css - 导航栏遮盖的内部引用目的地

python - 使用sphinx处理字符串

include - 不同文件的标题不匹配

python-sphinx - 带注释的 Sphinx toctree

python - opencv python将框架转换为灰色并写入新视频不起作用

python - QSTK 的 eventprofiler 函数绘制不正确

python - 使用 Sphinx 扩展自动生成 doctest 输出