3 ms·
How do all these libraries check comments? As far as I know, the Python ast library does not parse comments?
by president 12y ago
How do all these libraries check comments? As far as I know, the Python ast library does not parse comments?
- rcfox 12y agoThey check for docstrings. From PEP 257[0]: "A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition. Such a docstring becomes the __doc__ special attribute of that object." [0] http://legacy.python.org/dev/peps/pep-0257/ http://legacy.python.org/dev/peps/pep-0257/
- carlio 12y agoComments are available after tokenisation (https://docs.python.org/2/library/tokenize.html https://docs.python.org/2/library/tokenize.html). They're indeed not in the AST but you can get at them for analysis.