Parse comments from various source files.
Project description
### extract_comments Signature
def extract_comments(filename, mime=None):
"""Extracts and returns the comments from the given source file.
Args:
filename: String name of the file to extract comments from.
mime: Optional MIME type for file (str). Note some MIME types accepted
don't comply with RFC2045. If not given, an attempt to deduce the
MIME type will occur.
Returns:
Python list of parsers.common.Comment in the order that they appear in
the source file.
Raises:
UnsupportedError: If filename is of an unsupported MIME type.
"""
### Comments Interface
class Comment(object):
"""Represents comments found in source files."""
def text(self):
"""Returns the comment's text.
Returns:
String
"""
pass
def line_number(self):
"""Returns the line number the comment was found on.
Returns:
Int
"""
pass
def is_multiline(self):
"""Returns whether this comment was a multiline comment.
Returns:
True if comment was a multiline comment, False if not.
"""
pass
def __str__(self):
pass
def __eq__(self, other):
pass
## Supported Programming Languages
C
C++
Go
Java
Javascript
Shell scripts (Bash, sh, etc.)
More to come!
Check comment_parser.py for corresponding MIME types.
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
comment_parser-1.0.3.tar.gz
(4.8 kB
view details)
File details
Details for the file comment_parser-1.0.3.tar.gz
.
File metadata
- Download URL: comment_parser-1.0.3.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a14f186dcee232507de4707f85c59dcaa2ef39b20fe0df56349e2c225d048491 |
|
MD5 | 583e73b217c89fcfef4a6ca9c0eeaa8a |
|
BLAKE2b-256 | 234c175d8a7f8757fb0c2b254d4549079dbb118c92a63f7daf9453e14bc8d2da |
# Comment Parser
Python module used to extract comments from source code files of various types. ## Installation — ### Linux/Unix To install run ‘sudo pip3 install comment_parser’. ### OSX and Windows Complete the special installation requirements for python-magic. ## Usage — To use, simply run: