在sphinx中从侧边栏中删除多余的toctree

3

编辑:这篇帖子 似乎相关

我正在使用fulltoc 扩展在侧边栏中显示目录。

全局目录是在全局 index.rst 文件中定义的。它实际上是由一系列基本的 toctree 组成的:

.. toctree::
   :caption: Getting Started

   gettingStarted/overview
   gettingStarted/section1
   gettingStarted/section2

.. toctree::
   :caption: Next Large section

   group2/overview
   group2/section1
   group2/etc

overview.rst文件包含每个部分的描述以及接下来部分的toctree。在gettingStarted文件夹中,此文件如下:

Overview
========

This is a description of the section.

.. toctree::

   section1
   section2

问题在于查看页面gettingStarted/overview时,侧边栏会显示子目录,这会导致冗余的条目:

入门指南

  • 概述
    • 第一部分
    • 第二部分
  • 第一部分
  • 第二部分
而我更希望有以下内容:

入门指南

  • 概述
  • 第一部分
  • 第二部分
一个解决方法是降低:maxdepth:,但这样侧边栏就不会展开子部分,例如从某个部分(如gettingStarted/section1)阅读。
我还发现rubric指令,但无法弄清楚如何在toctree上使用它。
如何防止子目录被索引到全局目录中?
1个回答

0
你可以使用在PyPI上可用的。
pip install sphinx-remove-toctrees

文档可以在GitHub上找到:https://github.com/executablebooks/sphinx-remove-toctrees 你只需要创建一个名为remove_from_toctrees的列表,其中包含要从侧边栏中移除的页面的全局表达式,例如。
remove_from_toctrees = ["generated/api/*"]

请注意,路径的选择取决于平台,至少在此PR合并之前是这样的:https://github.com/executablebooks/sphinx-remove-toctrees/pull/4 或者您可以暂时从我的分支安装:
sphinx-remove-toctrees @ git+https://github.com/mscheltienne/sphinx-remove-toctrees

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接