4

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

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

我怎样才能做到这一点?

4

1 回答 1

2

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

#.  **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
于 2010-11-30T00:11:29.443 回答