def _parse_func_code(lines):
from inspect import cleandoc
if len(lines) == 1:
_ = lines[0].split(':', 1)
return [_[0] + ':'], '', _[1]
sig, doc = [], []
while lines:
l = lines.pop(0)
sig.append(l)
if l.rstrip().endswith(':'):
break
l = '\n'.join(lines).strip()
for apo in "'''", '"""', "'", '"', '':
if l.startswith(apo):
break
if not apo:
# no docstring
return sig, '', lines
l = l.split(apo, 2)
return sig, cleandoc(l[1]), l[2]
评论列表
文章目录