On Oct 17, 6:54 pm, "Edward K. Ream" <[email protected]> wrote:
> c.commandsDict makes this a snap::
Various callback functions and class objects complicate matters. This
works better:
d = c.commandsDict # Keys are command names, values are functions.
aList = list(d.keys())
aList.sort()
for key in aList:
f = d.get(key)
if hasattr(f,'__name__') and f.__name__ == 'minibufferCallback':
args, varargs, keywords, defaults = inspect.getargspec(f)
f = defaults[0]
if hasattr(f,'__name__') and f.__name__ ==
'commonCommandCallback':
args, varargs, keywords, defaults = inspect.getargspec(f)
script = defaults[1]
s = g.getDocString(script)
elif hasattr(f,'docstring'): # atButtonCallback object.
s = f.docstring(trace=True)
elif hasattr(f,'__doc__'):
s = f.__doc__ or ''
else:
print('**oops',f)
s = ''
else:
s = f.__doc__ or ''
print('%4s %s' % (len(s),key))
This uses the new g.getDocString function that finds the first
docstring in a string. @button and @command nodes generate callback
functions that store positions, not a compiled function, so the code
above has to find the docstring in p.b.
In any event, we now have a script that will highlight any commands
that lack a docstring. I'll repackage the code above into something
like c.getDocstringForCommand(command-name).
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.