@g.command('find-missing-docstrings')
def find_missing_docstrings(event):
'''Report missing docstrings in the log, with clickable links.'''
c = event.get('c')
if not c:
return
@others # Define functions
count, found, t1 = 0, [], time.clock()
for root in g.findRootsWithPredicate(c, c.p, predicate=is_root):
for p in root.self_and_subtree():
lines = p.b.split('\n')
for i, line in enumerate(lines):
if is_a_definition(line) and not has_docstring(lines, i):
count += 1
if root.v not in found:
found.append(root.v)
g.es_print('')
g.es_print(root.h)
print(line)
g.es(line, nodeLink=clickable_link(p, i+1))
break
g.es_print('')
g.es_print('found %s missing docstring%s in %s file%s in %5.2f sec.' % (
count, g.plural(count),
len(found), g.plural(len(found)),
(time.clock() - t1)))