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.2.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for ast_comments-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 655efdc602e0813b19bffaed7d53ac573bb6a5891db990c425af4afb32795a18 |
|
MD5 | ffbd4d5489e5b9a3259c4e5d2e2df353 |
|
BLAKE2b-256 | 4ef5f79b2a2082c3dff1ee9cbfc5f57b3e3c3a2b9a44c94323587b8054abf782 |