我有一个Python类似于以下的内容,其中docstrings旨在由Sphinx转换为文档:
class Direction(object):
"""
A direction in which movement can be made.
"""
def __init__(self):
self._name = None
@property
def name(self):
"""
The unique name of the direction.
:return: The direction name
:rtype: string
"""
return self._name
@name.setter
def name(self, value):
"""
Sets the direction name.
:param string value: The direction name
"""
self._name = value
Sphinx输出结果大致如下:
class Direction(name) 可以进行移动的方向。
name 方向的唯一名称。
返回值: 方向名称
返回类型: 字符串
这在一定程度上可以,但请注意完全没有关于name
设置器的任何信息。
有没有办法让Sphinx生成属性设置器的文档?
:param:
、:return:
和:rtype:
标签来澄清这一点。 - Matthew Murdoch()
。这个和你结合的文档字符串一起,应该能帮助用户理解它是一个属性。 - Asclepius