这些在Python文档字符串中的标签 @ivar、@param 和 @type 是什么意思?

16

安培计划在docstring中使用一些标签,例如类似于javadoc的标签。

例如来自pool.py第86行:

def start(self, ampChild=None):
    """
    Starts the ProcessPool with a given child protocol.

    @param ampChild: a L{ampoule.child.AMPChild} subclass.
    @type ampChild: L{ampoule.child.AMPChild} subclass
    """

这些标签是什么,哪个工具使用它。

2个回答

15

仅供娱乐,我想指出Python标准库正在使用Sphinx/reStructuredText,它们的信息字段列表很相似。

def start(self, ampChild=None):
    """Starts the ProcessPool with a given child protocol.

    :param ampChild: a :class:`ampoule.child.AMPChild` subclass.
    :type ampChild: :class:`ampoule.child.AMPChild` subclass
    """

5
同一编程语言有太多派系了!这可不好。 - Andrea Francia
7
@Andrea Francia:Epydoc非常轻量级(远不及reStructuredText强大),并且在reStructuredText被采用为标准之前就已经开发好了。它们都有存在的原因,但我建议用户从现在开始使用reStructuredText。 - cdleary
1
还有PEP 257中提到的轻量级符号,它不是针对工具,而是人类可读性。 - Karl Bartel

14

关于一款文档工具的标记语言,可能是epydoc


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接