【问题标题】:Different :maxdepth: for specific entries in toctree (Sphinx)不同的:maxdepth:用于目录树(Sphinx)中的特定条目
【发布时间】:2019-05-18 03:32:42
【问题描述】:

我有一些基于 Sphinx 的文档,用于我构建的一个库,我想为我的所有页面显示扩展的目录,但更改日志除外。我想出了如何通过将更改日志移动到第二个:toctree:: 来做到这一点,但这有一些奇怪的行为。主要是,当我访问页面时,更改日志显示在不同的项目符号列表中,当我使用侧边栏导航时,我只能在每个目录树内导航(如果我单击更改日志,我不会在侧边栏上显示其他部分)。有没有更好的方法来做到这一点?

这是我现在拥有的:

.. toctree::
   :maxdepth: 5

   getting_started
   examples
   modules

.. toctree::
   :maxdepth: 1

   changelog


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

【问题讨论】:

标签: python python-sphinx toctree


【解决方案1】:

使用Read the Docs 模板,您可以实现这一目标。您还必须操作 _static 目录中的 style.css 文件。只需添加

.rst-content .toctree-wrapper:not(:last-child) ul {
   margin-bottom: 0;
}

两个独立的目录树看起来像一个,它们将显示在侧栏中。

对于其他 Sphinx 模板,检查呈现的 html 可以引导您找到正确的 css 选择器。但我不知道这些模板是如何处理侧边栏的。

【讨论】:

    猜你喜欢
    • 2013-02-06
    • 1970-01-01
    • 2020-10-02
    • 2017-02-07
    • 2023-04-02
    • 1970-01-01
    • 2021-05-07
    • 2011-12-21
    相关资源
    最近更新 更多