extractComments (
text,
extractRe=re.compile( '^((?P\s*$)|(?P(?P\s*)(?P(class|def))\s+(?P[0-9A-Za-z_]+))|(?P\s*#+(?P.*)))' ).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.
|