使用单个 html 构建选项时如何包含 table 内容?

How to include table fo contents when using singlehtml build option?

上下文

我正在使用 Sphinx 创建技术文档(与代码无关)。输入是几个 reStructuredText 和 SVG 文件。输出是使用 singlehtml 构建器创建的(在后面的步骤中使用 weasyprint 将其转换为 PDF)。

问题

我想在最终文档中包含 table 个目录 (TOC)。 TOC(边栏)的默认位置不是一个选项。我必须 disable/hide 边栏才能生成有用的 PDF。

解决方案(我考虑/尝试过)

使用 contents directive.

Here's the directive in its simplest form:

.. contents::

Language-dependent boilerplate text will be used for the title. The English default title text is "Contents".

An explicit title may be specified:

.. contents:: Table of Contents

正如@mzjn 已经怀疑的那样,.. contents:: 只列出了当前文件的内容,但是 如果我使用 .. include:: 而不是 .. toctree:: 包括其他文件,它仍然有效。所以我目前使用的是:

.. sectnum::
.. contents:: Table of Contents
   :depth: 2

.. include:: intro.rst
.. include:: processes.rst