【问题标题】:Unexpected unindent python-sphinx意外的不缩进 python-sphinx
【发布时间】:2021-04-23 07:27:10
【问题描述】:

我的 python 项目中有以下 docString:

def challenge():
    """Route for POST a challenge.

    For call this route, we need to pass a serialNumber on body form.
    If this serialNumber is in the database and corresponds to a tablet we call methods for create challenge

    :returns: An HTTP response with a challenge

    EXAMPLE::
        REQUEST
            curl --location --request POST 'xxxx:xxxx/challenge'
            --form 'serialNumber="xxxxx"'
        RESPONSE
            {
                "challenge": "xxxx"
            }

    """

当我运行 make html 时,sphinx 给我以下错误:

docstring of src.modules.challenge.router.challenge:15: WARNING: Definition list ends without a blank line; unexpected unindent.

格式根本不是我想要的文档。我希望我的 API 的每条路由都以文本块或代码块的形式插入请求/响应示例。

【问题讨论】:

    标签: python python-sphinx docstring


    【解决方案1】:

    EXAMPLE::REQUEST 之间添加一个空行。

    块(段落)必须用空行与其他块分隔。见https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#literal-blocks

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-25
      • 1970-01-01
      • 1970-01-01
      • 2010-11-04
      相关资源
      最近更新 更多