Python和sphinx:多行google样式docstring中的项目符号列表

Python和sphinx:多行google样式docstring中的项目符号列表,python,python-sphinx,docstring,google-style-guide,Python,Python Sphinx,Docstring,Google Style Guide,我目前正在使用Sphinx记录我的Python项目。在文档字符串的多行部分包含项目符号列表时,我遇到了一个问题 我想包括一个项目清单,但其中一项是相当长的。我想: 通过Sphinx正确呈现项目符号列表 还有我关于PEP8行长的代码(你可以随心所欲地行。只需将续行与前几行文本对齐,如: - give a visual representation of that geography - give a visual representation of the distance matrix - g

我目前正在使用Sphinx记录我的Python项目。在文档字符串的多行部分包含项目符号列表时,我遇到了一个问题

我想包括一个项目清单,但其中一项是相当长的。我想:

  • 通过Sphinx正确呈现项目符号列表
  • 还有我关于PEP8行长的代码(你可以随心所欲地行。只需将续行与前几行文本对齐,如:

    - give a visual representation of that geography
    - give a visual representation of the distance matrix
    - give a visual representation of a configuration, a configuration being the
      repartition of some or all cities in pools
    
    来自的解决方案是完美的。我只想补充一点,它也适用于非项目符号列表。我对函数或方法的参数的注释也有类似的问题。例如:

    def permute_array(arr, seq):
    """ Function to "square permute" a 2D array
    
    This function's purpose is to enable distance matrices permutations. That 
    is, for example, permute both lines and columns of the array so as to 
    reorder a distance matrix.
    
    Args:
        arr (numpy array): the array to permute. It should be square of size n.
        seq (iterable of int): a permutation of range(n) (should be of length n and contain every integer from 0 to n-1)
    
    最后一行太长了

    但是,“相同缩进级别”的换行符只会破坏尼斯狮身人面像方法文档:

        Args:
            arr (numpy array): the array to permute. It should be square of size n.
            seq (iterable of int): a permutation of range(n) (should be of length n
            and contain every integer from 0 to n-1)
    

    但是,用一个标识来打破界限就行了

        Args:
            arr (numpy array): the array to permute. It should be square of size n.
            seq (iterable of int): a permutation of range(n) (should be of length n
                and contain every integer from 0 to n-1)
    

    谢谢你的回答,Stephen,我会在5分钟内尝试,并随时通知你。你好,Pierre,太棒了!这非常有效,我的医生仍然很好地构建,我现在遵守PEP 8。我将在尝试应用类似解决方案时,为非项目符号列表添加额外的注释。
        Args:
            arr (numpy array): the array to permute. It should be square of size n.
            seq (iterable of int): a permutation of range(n) (should be of length n
                and contain every integer from 0 to n-1)