generate.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:satori-rtm-sdk-python 作者: satori-com 项目源码 文件源码
def rst_sections_in_module(tree, module_name, exports):
    docstring = ast.get_docstring(tree)
    if docstring:
        yield docstring
    for toplevel in tree.body:
        try:
            if toplevel.name not in exports:
                continue
        except AttributeError:
            continue

        print(
            'Documenting {}.{}'.format(module_name, toplevel.name),
            file=sys.stderr)
        class_doc = ast.get_docstring(toplevel)
        if class_doc:
            yield toplevel.name + '\n' + '-' * len(toplevel.name)
            yield class_doc
            if type(toplevel) == ast.ClassDef:
                for fun in toplevel.body:
                    if type(fun) != ast.FunctionDef:
                        continue
                    fun_doc = ast.get_docstring(fun)
                    if fun_doc:
                        fun_sig = signature(module_name, toplevel.name, fun)
                        yield fun.name + '\n' + '+' * len(fun.name)
                        yield 'Signature:\n    ' + fun_sig
                        yield fun_doc
                    else:
                        if not fun.name.startswith('_'):
                            print('Missing docstring for ' + fun.name, file=sys.stderr)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号