def __str__(self):
out = ''
doclines = inspect.getdoc(self._f) or ''
try:
doc = SphinxDocString(doclines)
except Exception as e:
print('*' * 78)
print("ERROR: '%s' while parsing `%s`" % (e, self._f))
print('*' * 78)
# print "Docstring follows:"
# print doclines
# print '='*78
return out
if doc['Signature']:
out += '%s\n' % header('**%s**' %
doc['Signature'].replace('*', '\*'), '-')
else:
try:
# try to read signature
argspec = inspect.getargspec(self._f)
argspec = inspect.formatargspec(*argspec)
argspec = argspec.replace('*', '\*')
out += header('%s%s' % (self._f.__name__, argspec), '-')
except TypeError as e:
out += '%s\n' % header('**%s()**' % self._f.__name__, '-')
out += str(doc)
return out
评论列表
文章目录