带有sphinx新行的Python自动文档字符串

时间:2018-08-13 00:50:41

标签: python python-sphinx docstring

我想知道使用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 
"""

1 个答案:

答案 0 :(得分: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 
    """

正文元素由空白行分隔。该文档字符串由两个正文元素组成:常规paragraphline block