0

我想指定 Pydoc 记录我的函数的顺序。我不确定 Pydoc 如何在生成的文档中对函数进行排序——它肯定不是模块中的文本顺序。

这很有用,因为我想先指定printUsage()要记录的函数。

"""
Sample module docstring
"""

def printUsage():
    """
    Command line usage: python my_module.py -i path/to/input_file.c
    If calling my_function() directly, pass the path/to/input_file.c as an arg.
    """
    print(printUsage.__doc__)

...

因此,当用户签出 docstring 时my_module,他可以快速了解如何使用它。

4

1 回答 1

1

查看源代码

看起来模块文档存储为字典,因此当它们遍历它们时,它会创建随机顺序:

def namelink(self, name, *dicts):
    """Make a link for an identifier, given name-to-URL mappings."""
    for dict in dicts:
        if name in dict:
            return '<a href="%s">%s</a>' % (dict[name], name)
于 2015-02-27T00:40:24.657 回答