首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在不添加新文档的情况下在Sphinx toctree中添加标题?

如何在不添加新文档的情况下在Sphinx toctree中添加标题?
EN

Stack Overflow用户
提问于 2019-12-14 01:07:51
回答 1查看 2K关注 0票数 1

好的,我正在使用Sphinx Autosummary为一些类生成文档。有三种不同类型的类,我希望我的侧边栏有三个不同的部分,就像我在toctree指令中使用:caption:选项一样。

因此,我添加了将autosummary指令分隔为三个较小的指令,并在它们之间放置一个隐藏的toctree,如下所示:

代码语言:javascript
复制
Section 1

.. toctree::
   :hidden:
   :caption: Section 1

.. autosummary
   :toctree: stubs

   myclass
   anotherclass


Section 2

.. toctree::
   :hidden:
   :caption: Section 2

.. autosummary::
   :toctree:

   thirdclass

生成一个侧边栏,如:

代码语言:javascript
复制
myclass
anotherclass
thirdclass

这不管用。我的index.html的层次结构正是我想要的样子,但是侧边栏没有我的标题,它们没有显示出来。当我在这些隐藏的目录树下添加一个像self这样的页面时,标题就会显示出来:

代码语言:javascript
复制
Section 1

.. toctree::
   :hidden:
   :caption: Section 1

   self

.. autosummary
   :toctree: stubs

   myclass
   anotherclass


Section 2

.. toctree::
   :hidden:
   :caption: Section 2

.. autosummary::
   :toctree:

   thirdclass

生成一个侧边栏,如:

代码语言:javascript
复制
SECTION 1 (caption)
Documentation Home
myclass
anotherclass
thirdclass

这就是我要找的,但我不想引用self之类的东西。我只想要字幕。我该怎么做呢?

EN

回答 1

Stack Overflow用户

发布于 2019-12-15 18:36:13

toctree的目的是组织嵌套页面,它应该至少有一个条目(文件名)。否则,使用它就没有任何意义了。

下面的标记使用sphinx_rtd_theme生成所需的侧边栏。我知道它不能给你你想要的索引页,但我想不出其他的方法。将autosummary指令放在单独的文件中,并将每个文件作为toctree条目添加。

代码语言:javascript
复制
.. toctree::
   :caption: Section 1

   autosummary1

.. toctree::
   :caption: Section 2

   autosummary2
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59327002

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档