python 和狮身人面像 : bullet point list in multiline google style docstring

标签 python python-sphinx docstring google-style-guide

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

我想包括一个项目符号列表,但其中一项很长。我愿意:

  • 通过 Sphinx 正确呈现项目符号列表
  • 还有关于行长 (<79) 的 PEP8 代码

对于这个文档字符串,你会建议我做什么:

class geography():
""" Class defining a geography (cities and distance matrix)

This class implements a geography with a list of named cities with their
associated coordinates in a plane. Helper functions enable to :

- 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

...

最后一行超过 79 个字符。

然后通过 Sphinx 呈现评论。添加回车只会破坏 Sphinx 中的项目符号列表。

最佳答案

您可以 break the bulleted随心所欲。只需将延续与前几行文本对齐,例如:

- 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

关于 python 和狮身人面像 : bullet point list in multiline google style docstring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54677795/

相关文章:

python - 依赖文档字符串的脚本?

python - 我可以使用 argparse 帮助字符串来描述我的脚本返回值吗?

python - 随着 Bokeh 条形图上缩放级别的变化,是否可以保持相同数量的 x 轴刻度标签可见?

python re.sub组: number after\number

python - 如何通过索引替换 python 上的列表项

python - H2O Python - 如何获取变量类型,getTypes 等效

python - sphinx 参数部分之外的文本

python - 最终用户将如何访问 Sphinx 为 Python 包生成的文档?

python - 我想用我的文档呈现一个类(这是一个类)的属性

Python 文档字符串和内联代码; ">>>"语法的含义