Sphinx toctree指令:如何隐藏标题以防止显示?

6
如果我在index.rst中有以下内容:
This Section
------------

.. toctree::
   :caption: This Section
   :maxdepth: 1

   this_section/intro
   this_section/body
   this_section/outro

然后,“此部分”将在生成的HTML文件中显示两次:一次作为<h1>,一次作为<p class="caption">。我该如何摆脱后者,或使:caption:生成一个<h1>?我不能简单地删除:caption:,因为侧边栏(我正在使用ReadTheDoc主题)依赖于此选项来正确生成TOC树。

你找到了一个令人满意的解决方案/变通方法吗? - Mad
2个回答

2

我的解决方法是隐藏原始目录树,并重新链接到内容...

This section
------------

* :doc:`intro <this_section/intro>`
* :doc:`body <this_section/body>`

.. toctree::
   :caption: This Section
   :hidden:

   this_section/intro
   this_section/body
   this_section/outro


两个答案都可以很好地工作,但我认为这个应该被接受。 - Luiz Tauffer

2

我最终通过在_static目录下的custom.css中添加以下内容,使用css将其删除:

section#setup span.caption-text {
    display: none;
}

在我的conf.py中有以下内容:

html_static_path = ['_static']
html_css_files = ['custom.css']

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