【问题标题】:Python auto docstring with sphinx new line带有 sphinx 新行的 Python 自动文档字符串
【发布时间】:2018-08-13 00:50:40
【问题描述】:

我想知道在使用 Sphinx 生成自动文档时如何换行。我没有使用默认的 Sphinx 文档字符串格式 reStructuredText,但我使用的是 Numpydoc 格式。我尝试使用 '\n' 但它会换行,我只需要一个新行。这是一个 Python 模块的示例...

""" This is the first sentences 
| this is the second sentence at line 2 ... note that vertical bar 
| this is the second sentence at line 3 ... note that vertical bar 
...... 
def function1 (input):
    """ this function docstring starts here
    | this is not sentence number 2 at the vertical bar is not working 
    | this is not sentence number 3 at the vertical bar is not working 
    | this is not sentence number 4 at the vertical bar is not working 
"""

【问题讨论】:

标签: python python-sphinx docstring numpydoc


【解决方案1】:

只需在第一行之后添加一个空行:

def function1 (input):
    """ this function docstring starts here

    | this is not sentence number 2 at the vertical bar is not working 
    | this is not sentence number 3 at the vertical bar is not working 
    | this is not sentence number 4 at the vertical bar is not working 
    """

正文元素由空行分隔。文档字符串由两个正文元素组成:一个常规的paragraph 和一个line block

【讨论】:

    猜你喜欢
    • 2022-09-30
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 2012-04-18
    • 1970-01-01
    • 1970-01-01
    • 2014-08-19
    相关资源
    最近更新 更多