No project description provided
Project description
ast-comments
An extension to the built-in ast
module.
Finds comments in source code and adds them to the parsed tree.
Installation
pip install ast-comments
Usage
There is no difference in usage between ast
and ast-comments
>>> import ast_comments as astcom
>>> tree = astcom.parse("hello = 'hello' # comment to hello")
Parsed tree is instance of the original ast.Module object
>>> tree
<_ast.Module object at 0x7ffba52322e0>
Any "statement" node of the tree has comments
field
>>> tree.body[0].comments
('comment to hello',)
>>> astcom.dump(tree)
"Module(body=[Assign(targets=[Name(id='hello', ctx=Store())], value=Constant(value='hello', kind=None), type_comment=None, comments=('comment to hello',))], type_ignores=[])"
Contributing
You are welcome to open an issue or create a pull request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ast_comments-0.1.3.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for ast_comments-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b6d2e56657b60c172041b1565dbf24bfcbf57791a734b25a98fe4112de98191 |
|
MD5 | ca483df42455e748e4b8fb12ca3b848d |
|
BLAKE2b-256 | a49a1419fb7f65a6bfe8feda520862da88d53874513dff263a1e48b53d74efae |