在Google风格的Python docstring中,可以指定Args
、Returns
、Raises
,如下所示。在
"""This is an example of Google style.
Args:
param1: This is the first param.
param2: This is a second param.
Returns:
This is a description of what is returned.
Raises:
KeyErr
"""
我有很多函数,它们不返回数据,而是将结果写入磁盘。我发现记录函数将要写入磁盘的内容通常很有用,例如使用Writes:
,这似乎不受{
最好的办法是什么?在
对于版本
sphinx>=1.8.2
,可以使用custom section。在在您的
conf.py
中,您应该添加选项napoleon_custom_sections = ('Writes', 'Parameters')
(例如,用参数创建别名)然后您可以这样编写docstring:
相关问题 更多 >
编程相关推荐