如何在 Sphinx 的主目录中隐藏部分标题?

问题描述

我正在为使用 Sphinx 的 Python 项目编写文档。主页有一个目录,认情况下,Sphinx 中的 toctree 指令包括页面标题下方的部分标题。我觉得这太过分了,在可用性方面。直觉上,我希望每页有一个链接。为所有部分提供子链接使文档看起来比实际情况复杂得多。

:titlesonly: 选项修复了这个问题,但实际上在页面上时也会从侧边栏删除部分标题。我不想丢失它们,因为它们是有用的“当前页面”目录。

有没有办法将部分标题首页的目录中排除,同时将它们保留在侧边栏中?

没有 :titlesonly: 的示例

index.rst:

Example Documentation
=====================

Table of Contents
-----------------

.. toctree::
   :maxdepth: 2

   installation
   api
   support

installation.rst:

Installation
============

From PyPI
---------

Lorem ipsum dolor sit amet...

From Source
-----------

Lorem ipsum dolor sit amet...

(其他 .rst 文件以此类推)

index.html:

enter image description here

installation.html:

enter image description here

:titlesonly: 示例

index.rst:

Example Documentation
=====================

Table of Contents
-----------------

.. toctree::
   :maxdepth: 2
   :titlesonly:

   installation
   api
   support

(其他 .rst 文件不变)

index.html:

enter image description here

installation.html

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)