如何重置 Sphinx 中的编号部分?

How to reset numbered sections in Sphinx?

我有几个相互独立的文档:

index.rst
foo.rst
bar.rst
conf.py
Makefile

我想从 index.rst 访问 foo.rst,但我希望这两个子文档从 1 开始编号。

index.rst 我有:

.. toctree::
   :maxdepth: 2
   :numbered:

   foo
   bar

但是,bar 将取数字 2.,使用这个 bar.rst 我将得到 2.1 Tomatoes

=====
Title
=====

Tomatoes
========

Cucumbers
=========

我想要这个效果图:

1. Tomatoes
2. Cucumbers

这怎么可能?

你不能两全其美。有关解释,请参阅 Section numbering under the toctree directive 的 Sphinx 文档:

Section numbering

If you want to have section numbers even in HTML output, give the toplevel toctree a numbered option. For example:

.. toctree::
  :numbered:

  foo
  bar

Numbering then starts at the heading of foo. Sub-toctrees are automatically numbered (don’t give the numbered flag to those).