可以用AST解析模块级docstring吗?在
我正在研究一个python文档管理器here,访问模块令牌并获取文档不会生成模块级docstring。到目前为止,我不得不求助于导入模块并获取它的__doc__
,或者使用inspect
来获取文档。在
我在pydoc module源代码中寻找其他文档编制者如何解析docstring的线索,发现pydoc最终不得不做与我的文档编制者基本相同的事情,才能获取模块级字符串。在
我错过什么了吗?是通过实际导入模块来解析模块级docstring的唯一方法,还是可以直接从AST解析docstring?在
Tags:
也许我没能理解这个问题,但你就不能这么做(Python2.7.1)?在
测试文件:
互动环节:
^{pr2}$您还可以遍历ast,寻找doc字符串所在的插槽。在
相关问题 更多 >
编程相关推荐