方法肯定是 reStructuredText 和 Sphinx,后者只有在您想要生成 HTML 或 PDF 文档时才使用。这也是 Python 库本身的记录方式。几个月前,我从 epydoc 切换到 reStructuredText,因为后者的一般支持要好得多。
您的文档字符串将如下所示:
def myfunc(p1, p2, p3):
"""myfunc does something interesting.
some more detail. See :meth:`my_other_func` for more information.
:param p1: The first parameter.
:type p1: string
:param p2: The second parameter.
:param p3: The third parameter.
:returns: True if successful, False if not.
"""
my_code(p1)
more_code(p2)
return third_part(p1,p2,p3)