0

pydoc用来创建文档。但它只显示docstring一个类和方法,如__init__. 是否还有任何参数要传递给为类的每个方法pydoc创建文档?

例子:

class myclass(some_other_class):
    """
    This is 'class' docstring.
    """

    def __init__(self):
       """
       This is docsctring for __init__ method.
       """
       pass

    def mymethod(self, some_parameter):
       """
       This is docstring for mymethod function.
       """
       pass

现在,当我在此代码上使用 pydoc 时,我看不到“这是 mymethod 函数的文档字符串”。在生成的输出中。

4

1 回答 1

1

你的代码看起来非常好,我把它放在一个script.py文件中,删除了“some_other_class”引用,然后运行python -m pydoc -w script​​. 它生成了以下 HTML:

class myclass
      This is 'class' docstring.

      Methods defined here:
          __init__(self)
            This is docsctring for __init__ method.
          mymethod(self, some_parameter)
            This is docstring for mymethod function.
于 2014-10-14T08:57:50.777 回答