代码之家  ›  专栏  ›  技术社区  ›  Kernel

带sphinx新行的Python自动docstring

  •  0
  • Kernel  · 技术社区  · 6 年前

    我想知道,在使用Sphinx生成自动文档时,如何才能有一个新的行。我没有使用默认的Sphinx docstring格式structuredtext,而是使用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 回复  |  直到 5 年前
        1
  •  1
  •   mzjn    6 年前

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

    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 
        """
    

    正文元素用空行分隔。docstring由两个body元素组成:regular paragraph 以及 line block

    推荐文章