https://github.com/kelvintaywl/code_comment
extracts comments from your source code (pip install code_comment)
https://github.com/kelvintaywl/code_comment
comments extraction parser source-code
Last synced: 5 months ago
JSON representation
extracts comments from your source code (pip install code_comment)
- Host: GitHub
- URL: https://github.com/kelvintaywl/code_comment
- Owner: kelvintaywl
- License: mit
- Archived: true
- Created: 2017-08-20T04:17:34.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-08-20T15:40:18.000Z (almost 8 years ago)
- Last Synced: 2025-09-07T14:58:00.278Z (9 months ago)
- Topics: comments, extraction, parser, source-code
- Language: Python
- Homepage: https://pypi.python.org/pypi/code-comment
- Size: 7.81 KB
- Stars: 3
- Watchers: 2
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Code Comment
[](https://travis-ci.org/kelvintaywl/code_comment)
Parser to extract code comments in source codes.
> Requires Python 3.3+
## Supported Languages
- Go
- Javascript
- PHP
- Python
## Example Usage
### Example file (`dummy.py`)
```python
""" Dummy
Lorem Ipsum
"""
def main():
# nothing to see here!
# しかし、日本語でも大丈夫だよ!
print('Hello Python')
if __name__ == '__main__':
""" Test single-line multiline comment """
main()
```
```python
import code_comment
filepath = 'dummy.py'
for comment in code_comment.extract(filepath):
do_something_with_comment(comment)
comments = list(code_comment.extract(filepath))
assert len(comments) == 4
first_comment = comments[0]
assert first_comment.is_multiline
assert first_comment.line_number_str = '1~3'
assert first_comment.filepath = 'dummy.py'
assert first_comment.body_str = 'Dummy\nLorem Ipsum\n'
print(str(first_comment))
# [dummy.py:1~3] Dummy
# Lorem Ipsum
```