mirror of
https://github.com/ejwa/gitinspector.git
synced 2024-12-22 13:42:14 +01:00
Added support for comments in LaTex (.tex) files (Fixes issue 8).
Even though it is supported, LaTex is not part of the default file extensions used during analysis. To include LaTex files in the statistical analysis, the extension (.tex) needs to be supplied to gitinspector using the -f flag.
This commit is contained in:
parent
aec012b877
commit
16701a4d51
1 changed files with 15 additions and 9 deletions
|
@ -20,13 +20,15 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
__comment_begining__ = {"java": "/*", "c": "/*", "cpp": "/*", "h": "/*", "hpp": "/*", "html": "<!--", "php": "/*",
|
||||
"py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*", "sql": "/*", "xml": "<!--"}
|
||||
"py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*", "sql": "/*", "tex": "\\begin{comment}", "xml": "<!--"}
|
||||
|
||||
__comment_end__ = {"java": "*/", "c": "*/", "cpp": "*/", "h": "*/", "hpp": "*/", "html": "-->", "php": "/*",
|
||||
"py": "\"\"\"", "glsl": "*/", "rb": "=end", "js": "*/", "sql": "*/", "xml": "-->"}
|
||||
"py": "\"\"\"", "glsl": "*/", "rb": "=end", "js": "*/", "sql": "*/", "tex": "\\end{comment}", "xml": "-->"}
|
||||
|
||||
__comment__ = {"java": "//", "c": "//", "cpp": "//", "h": "//", "hpp": "//", "pl": "#", "php": "//", "py": "#",
|
||||
"glsl": "//", "rb": "#", "js": "//", "sql": "--"}
|
||||
"glsl": "//", "rb": "#", "js": "//", "sql": "--", "tex": "%"}
|
||||
|
||||
__comment_markers_must_be_at_begining__ = {"tex": True}
|
||||
|
||||
def is_comment(extension, string):
|
||||
if __comment_begining__.get(extension, None) != None and string.strip().startswith(__comment_begining__[extension]):
|
||||
|
@ -39,13 +41,17 @@ def is_comment(extension, string):
|
|||
return False
|
||||
|
||||
def has_comment_begining(extension, string):
|
||||
if __comment_begining__.get(extension, None) != None and string.find(__comment_end__[extension], 2) == -1:
|
||||
if __comment_markers_must_be_at_begining__.get(extension, None) == True:
|
||||
return string.find(__comment_begining__[extension]) == 0
|
||||
elif __comment_begining__.get(extension, None) != None and string.find(__comment_end__[extension], 2) == -1:
|
||||
return string.find(__comment_begining__[extension]) != -1
|
||||
else:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
def has_comment_end(extension, string):
|
||||
if __comment_end__.get(extension, None) != None:
|
||||
if __comment_markers_must_be_at_begining__.get(extension, None) == True:
|
||||
return string.find(__comment_end__[extension]) == 0
|
||||
elif __comment_end__.get(extension, None) != None:
|
||||
return string.find(__comment_end__[extension]) != -1
|
||||
else:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
|
Loading…
Reference in a new issue