Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.
/ code_comment Public archive

extracts comments from your source code (pip install code_comment)

License

Notifications You must be signed in to change notification settings

kelvintaywl/code_comment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Comment

Build Status

Parser to extract code comments in source codes.

Requires Python 3.3+

Supported Languages

  • Go
  • Javascript
  • PHP
  • Python

Example Usage

Example file (dummy.py)

""" Dummy
Lorem Ipsum
"""


def main():
    # nothing to see here!
    # しかし、日本語でも大丈夫だよ!
    print('Hello Python')


if __name__ == '__main__':
    """ Test single-line multiline comment """
    main()
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

About

extracts comments from your source code (pip install code_comment)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages