Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Sphinx:将代码段放在无序列表项的第一行_Python_Restructuredtext_Python Sphinx - Fatal编程技术网

Python Sphinx:将代码段放在无序列表项的第一行

Python Sphinx:将代码段放在无序列表项的第一行,python,restructuredtext,python-sphinx,Python,Restructuredtext,Python Sphinx,我正在使用Sphinx来管理我的项目文档 我有一个无序的列表,我希望每个项目的第一行是一个代码段。(不是内联的,是段落。) 我如何才能做到这一点?查看我自己的文档,我发现了一个类似的场景,但是我不能保证它将作为列表中的第一个文本与文档一起工作: #. **Defining the Model Class** All models must inherit from |LrbBaseModel| either directly or indirectly and have th

我正在使用Sphinx来管理我的项目文档

我有一个无序的列表,我希望每个项目的第一行是一个代码段。(不是内联的,是段落。)


我如何才能做到这一点?

查看我自己的文档,我发现了一个类似的场景,但是我不能保证它将作为列表中的第一个文本与文档一起工作:

#.  **Defining the Model Class**

    All models must inherit from |LrbBaseModel| either directly or
    indirectly and have the |LrbModelInit| decorator above their
    constructor (a.k.a. ``__init__``)::

        class foo(LrbBaseModel):
            @LrbModelInit()
            def __init__(self):
                ...
这将产生:

我认为,您可以通过代码块而不必像下面这样预编译文本:

#.  ::
        def fooDeFaFa():
            pass
请注意,我的代码块缩进了两次。
::
表示空的文本段落块,然后我的代码通过第二次缩进成为该
语法的子代码

或者,这可能会起作用:

#.
    ::
        def fooDeFaFa():
            pass
。::将完美工作;在列表项中,它只是一个非常普通的段落,因此
将按预期工作。为了简单起见,请尝试一下。请注意,尽管他确实说无序-
*::
-:
出于这个原因,会更准确。