从我的Django文件中提取所有docstring(\uuu doc_uu)

2024-07-03 05:44:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Django有一个项目,我在我的模块、类和函数中编写docstring。但我需要一种方法从那里自动提取所有__doc__。就像“Python”管理.pycollectstatic”,但对于所有.py代码的.__doc__实例。像那样的?有什么想法吗?在


Tags: 模块项目django实例方法函数代码py
1条回答
网友
1楼 · 发布于 2024-07-03 05:44:23

让你一睹^{}

示例模块:

# foo.py

def bar():
  """this is the docstring for bar()"""
  print 'hello'


def baz():
  """this is the docstring for baz()"""
  print 'world'

现在可以使用以下命令打印docstrings:

^{pr2}$

也可以生成HTML帮助文件:

^{3}$

看起来像这样:

enter image description here

相关问题 更多 >