def document(cls, name, cache):
res = []
for func, types, _ in cache:
doc = (func.__doc__ or '').split('\n')
if len(doc) > 1:
res.append("{:s} ->".format(cls.prototype(func, types)))
res.extend("{: >{padding:d}s}".format(n, padding=len(name)+len(n)+1) for n in map(operator.methodcaller('strip'), doc))
elif len(doc) == 1:
res.append(cls.prototype(func, types) + (" -> {:s}".format(doc[0]) if len(doc[0]) else ''))
continue
return '\n'.join(res)
评论列表
文章目录