从sphinx的侧栏中删除多余的目录树

2024-05-15 11:44:04 发布

您现在位置:Python中文网/ 问答频道 /正文

编辑:this other post似乎有关联

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

全局目录在索引.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包含每个部分的描述和后面部分的目录树。在gettingStarted文件夹中,此文件如下所示:

^{pr2}$

问题是,当查看页面gettingStarted/overview时,侧边栏会显示子目录,这会产生多余的条目:

Getting Started

  • Overview
    • section1
    • section2
  • section1
  • section2

我宁愿去的地方

Getting Started

  • Overview
  • section1
  • section2

一种解决方法是降低:maxdepth:,但是当从一个节(例如gettingStarted/section1)读取时,侧边栏不会展开子节。在

我还找到了^{}指令,但无法确定如何使它在toctree上工作。在

如何防止子目录被编入全球目录?在


Tags: 文件目录编辑overviewrstthisstartedgetting