python-sphinx - Sphinx:在笔记部分之后恢复列表编号

标签 python-sphinx restructuredtext continuation numbered-list

考虑ReStructuredText中的以下列表:

Broken list example
-------------------

#. First do spam
#. Then do ``eggs``

  .. note::

    Nobody expects the Spanish Inquisistion

#. The list restarts after the note


Sphinx中编译列表时,注释后面的数字将重置为1



知道如何在note部分后继续编号列表吗?

最佳答案

列表的不连续性是由于note是一个独立元素,而不是第二个编号列表元素的子元素。为防止列表不连续,请在与预期父编号列表元素的文本相同的缩进处(本例中为3个空格)开始note指令。因此,请尝试执行以下操作,而不是使用示例reStructuredText:

Fixed list example
------------------

#. First do spam
#. Then do ``eggs``

   .. note::

      Nobody expects the Spanish Inquisistion

#. Then do spam and ``eggs``.


这是关于reStructuredText的事情之一,既不容易发现,也没有特别好的文档记录;参见this question on nested lists for a closely-related problem

关于python-sphinx - Sphinx:在笔记部分之后恢复列表编号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29354305/

相关文章:

python - 带有 reStructuredText 的项目符号列表中的源代码

doc - 在 RestructuredText 中绘制数据库架构或状态机图形

crash - 调用延续时图像卡住

f# - Delay 在 Continuation monad 中到底是如何工作的以防止 stackoverflow?

python - 如何使用 Sphinx apidoc 仅记录在 __init__.py 中导入的 Python 类?

python-sphinx - 有没有一种方法可以在 plt.show() 之后用 sphinx 显示绘图或在 ..plot::之后保持范围

python - 使用 Sphinx 的 sphinx-apidoc 实用程序从 python 代码自动生成文档

python - docutils/sphinx 自定义指令创建兄弟部分而不是子部分

具有字符串连接和延续的 Python str.format

python - 如何以纯数据格式获取 Python Sphinx 文档?