The find-missing-docstrings command is hugely faster than running pylint.
This command uses Vitalije's is_definition_line and has_docstring function.
Credit is given.
The command is a rewrite using g.findRootsWithPredicate:
@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)))
Here is is_root:
def is_root(p):
'''A predicate returning True if p represents an external python file
that is not under @nopylint.'''
for parent in p.self_and_parents():
if g.match_word(parent.h, 0, '@nopylint'):
return False
return p.isAnyAtFileNode() and p.h.strip().endswith('.py')
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/de322355-a49b-4feb-b9a9-3b6347ffe088%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.