【问题标题】:How to make Pydoc document my functions in a specific order?如何让 Pydoc 以特定顺序记录我的函数?
【发布时间】:2015-02-26 22:14:53
【问题描述】:

我想指定 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__)

...

这样当用户签出my_module 的文档字符串时,他可以快速了解如何使用它。

【问题讨论】:

    标签: python pydoc


    【解决方案1】:

    看着sourcecode

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

    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)
    

    【讨论】:

    • 所以,我猜是死路一条?或者可以调整一些东西吗?
    • 如果您想编辑源代码,欢迎您。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-17
    相关资源
    最近更新 更多