def parse_func(n, func, prefix, f, s, typ='function'):
'''inspect function signature
# TODO: py3 inspect changed.
'''
prefix += (n,)
s.doc[prefix] = {'t': typ, 'd': getsource(func)}
fn = '.'.join(prefix[1:])
if not matches(fn, f.fmatch):
return
s.funcs.append(fn)
args = getargspec(func)
m = { 'pos_args': [], 'doc': doc_tag_line(f, func)
, 'arg_keys': args.args, 'args': {}}
defs = list(args.defaults or ())
for a in reversed(args.args):
d = m['args'][a] = defs.pop() if defs else 'n.d.'
if d == 'n.d.':
m['pos_args'].insert(0, a)
#m['sig'] = getsig(func, args, m)
s.reg[fn] = m
l('added', 'function' , prefix)
评论列表
文章目录