使用单个 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。
解决方案(我考虑/尝试过)
toctree
directive: 似乎只对侧边栏有效,不管我怎么试。
- HTML Theming:我用它来设置 HTML 输出的样式,但我不知道如何解决 TOC 问题。
- Sphinx extensions: 我自己写的,但是不是很灵活,我仍然确定其他人已经解决了这个问题。
- 使用
latexpdf
构建器:尝试过它并解决了 TOC 问题,但它产生了一些其他问题并且使用 CSS.
- Sphinx 以外的其他工具:这是 XY 问题的典型案例吗?我想使用 reStructuredText 和 SVG 生成 PDF,但我愿意使用 Sphinx 以外的其他东西。
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
上下文
我正在使用 Sphinx 创建技术文档(与代码无关)。输入是几个 reStructuredText 和 SVG 文件。输出是使用 singlehtml
构建器创建的(在后面的步骤中使用 weasyprint 将其转换为 PDF)。
问题
我想在最终文档中包含 table 个目录 (TOC)。 TOC(边栏)的默认位置不是一个选项。我必须 disable/hide 边栏才能生成有用的 PDF。
解决方案(我考虑/尝试过)
toctree
directive: 似乎只对侧边栏有效,不管我怎么试。- HTML Theming:我用它来设置 HTML 输出的样式,但我不知道如何解决 TOC 问题。
- Sphinx extensions: 我自己写的,但是不是很灵活,我仍然确定其他人已经解决了这个问题。
- 使用
latexpdf
构建器:尝试过它并解决了 TOC 问题,但它产生了一些其他问题并且使用 CSS. - Sphinx 以外的其他工具:这是 XY 问题的典型案例吗?我想使用 reStructuredText 和 SVG 生成 PDF,但我愿意使用 Sphinx 以外的其他东西。
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