这些标签@ivar @param和python docstring中的@type是什么?

And*_*cia 15 python documentation javadoc

安瓿项目在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
    """
Run Code Online (Sandbox Code Playgroud)

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

S.L*_*ott 14

文档工具的标记,可能是epydoc.

  • 是的,它们在http://epydoc.sourceforge.net/manual-fields.html中解释 (2认同)

cdl*_*ary 14

为了好玩,我会注意到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
    """
Run Code Online (Sandbox Code Playgroud)

  • @Andrea Francia:Epydoc非常轻量级(远不如reStructuredText那么强大),并且在reStructuredText被用作标准之前就开发得很好.它们都有充分的理由存在,但我建议用户从这里开始使用reStructuredText. (7认同)
  • 对于相同的编程语言有多少对流!坏事. (5认同)