extractComments (
text,
extractRe=re.compile( '^((?P<blankline>\s*$)|(?P<namedobj>(?P<indent>\s*)(?P<nametype>(class|def))\s+(?P<name>[0-9A-Za-z_]+))|(?P<commentline>\s*#+(?P<comment>.*)))' ).search,
ignoreRe=re.compile( '\s*[+-=#][ +-=#]*\s*$' ).match,
)
Given a block of Python source, extract the comments.
The comment text is associated with nearby named objects
(functions, methods, classes, etc.). This function returns
a dictionary of names and the associated comment text.
Arguments
- text
- The Python source to be scanned.
|