Metadata-Version: 2.1
Name: ast-comments
Version: 0.1.1
Summary: 
Home-page: https://github.com/t3rn0/ast-comments
Author: Dmitry Makarov
Author-email: dmtern0vnik@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Project-URL: Repository, https://github.com/t3rn0/ast-comments
Description-Content-Type: text/markdown

# 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
