如何在 Sphinx 中使用自动编号制作嵌套列表?
How to make nested lists with automatic numbering in Sphinx?
我正在使用 Sphinx 为 Python 程序编写文档。
我想创建一个带嵌套列表和自动编号的有序列表。
我想获得这样的东西:
Here it follows a numbered list
- This is the first item of the list
- This is the second one
- The second item has a nested list with two items
- this is the last item of the nested list
- The parent list continues with its third item
如果我明确使用数字作为编号列表,一切都很好。当我想使用自动编号时,问题就出现了,因为我想保持灵活性。名单很长,以后可能会改变,我不想在介绍新项目时更改所有数字。
我试过使用以下代码:
Here it follows a numbered list
#. This is the first item of the list
#. This is the second one
* The second item has a nested list with two items
* this is the last item of the nested list
#. The parent list continues with its third item
我得到的结果如下:
Here it follows a numbered list
- This is the first item of the list
This is the second one
- The second item has a nested list with two items
- this is the last item of the nested list
.1. The parent list continues with its third item
[我必须为第 3 个项目添加一些字符,这里是一个点,或者 Whosebug 中的降价系统显示 3!]
可以看到嵌套列表从头开始重新编号后的编号。
您必须正确缩进嵌套项目符号列表的两项以匹配父列表的文本,因此只需添加一个 space,如下所示:
#. This is the first item of the list
#. This is the second one
* The second item has a nested list with two items
* this is the last item of the nested list
#. The parent list continues with its third item
完整解释
我正在使用 Sphinx 为 Python 程序编写文档。 我想创建一个带嵌套列表和自动编号的有序列表。
我想获得这样的东西:
Here it follows a numbered list
- This is the first item of the list
- This is the second one
- The second item has a nested list with two items
- this is the last item of the nested list
- The parent list continues with its third item
如果我明确使用数字作为编号列表,一切都很好。当我想使用自动编号时,问题就出现了,因为我想保持灵活性。名单很长,以后可能会改变,我不想在介绍新项目时更改所有数字。
我试过使用以下代码:
Here it follows a numbered list
#. This is the first item of the list
#. This is the second one
* The second item has a nested list with two items
* this is the last item of the nested list
#. The parent list continues with its third item
我得到的结果如下:
Here it follows a numbered list
- This is the first item of the list
This is the second one
- The second item has a nested list with two items
- this is the last item of the nested list
.1. The parent list continues with its third item
[我必须为第 3 个项目添加一些字符,这里是一个点,或者 Whosebug 中的降价系统显示 3!]
可以看到嵌套列表从头开始重新编号后的编号。
您必须正确缩进嵌套项目符号列表的两项以匹配父列表的文本,因此只需添加一个 space,如下所示:
#. This is the first item of the list
#. This is the second one
* The second item has a nested list with two items
* this is the last item of the nested list
#. The parent list continues with its third item
完整解释