加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

文档 – Restructuredtext页面中的非TOC标题

发布时间:2020-12-20 11:30:12 所属栏目:Python 来源:网络整理
导读:我正在使用Sphinx编写一些文档. 有没有办法在页面中格式化标题而不成为TOC的一部分? 理想情况下,某些层次结构会反映在格式化中? 例如.我想要做 My page TOC heading===================Subheading (not in TOC,and should be formatted e.g. smaller than
我正在使用Sphinx编写一些文档.

有没有办法在页面中格式化标题而不成为TOC的一部分?
理想情况下,某些层次结构会反映在格式化中?

例如.我想要做

My page TOC heading
===================

Subheading (not in TOC,and should be formatted e.g. smaller than the heading)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Sub-subheading (not in TOC,and formatted e.g. smaller than the subheading)
###########################################################################

关于如何标记文本以使其具有更加结构化的外观的任何其他建议也是受欢迎的.

解决方法

Docutils,reStructuredText的参考实现,在其上构建Sphinx允许您将选项传递到 table of contents directive,这允许您控制您希望目录进入文档层次的深度.从 reStructuredText documentation开始,contents指令采用深度选项:

depth : integer

The number of section levels that are collected in the table of contents.
The default is unlimited depth.

因此,为了使您的文档结构只包含目录中包含的顶级标题,您可以使用

.. contents: Table of Contents
   :depth: 1

编辑:似乎Sphinx实现了自己的table of contents directive,所以你可以使用

.. toctree: Table of Contents
   :maxdepth: 1

而不是上面的第一个代码块.另外,看一下隐藏选项,这可能有助于进一步控制目录中包含的级别.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读