diff --git a/README.md b/README.md index a295787..d4db4b1 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,7 @@ These will be applied automatically to every issue, but will be overrode by any - Julia - Kotlin - Less +- Makefile - Markdown - Nix - Objective-C diff --git a/main.py b/main.py index 371c6f6..2abd73a 100644 --- a/main.py +++ b/main.py @@ -550,16 +550,28 @@ def parse(self, diff_file): issue.org_projects = separated_org_projects return issues + def _get_language_details(self, language_name, attribute, value): + """Try and get the Markdown language and comment syntax + data based on a specified attribute of the language.""" + attributes = [at.lower() for at in self.languages_dict[language_name][attribute]] + if value.lower() in attributes: + for syntax_details in self.syntax_dict: + if syntax_details['language'] == language_name: + return syntax_details['markers'], self.languages_dict[language_name]['ace_mode'] + return None, None + def _get_file_details(self, file): """Try and get the Markdown language and comment syntax data for the given file.""" file_name, extension = os.path.splitext(os.path.basename(file)) for language_name in self.languages_dict: - if 'extensions' in self.languages_dict[language_name]: - language_extensions = [ex.lower() for ex in self.languages_dict[language_name]['extensions']] - if extension.lower() in language_extensions: - for syntax_details in self.syntax_dict: - if syntax_details['language'] == language_name: - return syntax_details['markers'], self.languages_dict[language_name]['ace_mode'] + if extension != "" and 'extensions' in self.languages_dict[language_name]: + syntax_details, ace_mode = self._get_language_details(language_name, 'extensions', extension) + if syntax_details is not None and ace_mode is not None: + return syntax_details, ace_mode + elif 'filenames' in self.languages_dict[language_name]: + syntax_details, ace_mode = self._get_language_details(language_name, 'filenames', file_name) + if syntax_details is not None and ace_mode is not None: + return syntax_details, ace_mode return None, None def _extract_issue_if_exists(self, comment, marker, code_block): diff --git a/syntax.json b/syntax.json index 9b98227..b59b51b 100644 --- a/syntax.json +++ b/syntax.json @@ -764,5 +764,14 @@ } } ] + }, + { + "language": "Makefile", + "markers": [ + { + "type": "line", + "pattern": "#" + } + ] } ] diff --git a/tests/test_closed.diff b/tests/test_closed.diff index 568838e..0836a41 100644 --- a/tests/test_closed.diff +++ b/tests/test_closed.diff @@ -374,4 +374,21 @@ index 0000000..a6c6cb0 - /* - TODO fill this with something useful - */ - } \ No newline at end of file + } +diff --git a/tests/Makefile b/tests/Makefile +index 2996176..7545ccf 100644 +--- a/tests/Makefile ++++ b/tests/Makefile +@@ -1,12 +1,9 @@ +-# TODO change name. + NAME = asm + +-# TODO source files must be explicitly named. + SRC = $(shell find mandatory/src -name "*.asm") + OBJ = $(patsubst src/%.asm, obj/%.o, $(SRC)) + .PHONY: all + all: $(NAME) + $(NAME): $(OBJ) +- # TODO create the directory. + $(AR) rc $@ $(OBJ) + diff --git a/tests/test_new.diff b/tests/test_new.diff index e3c4272..8662a4b 100644 --- a/tests/test_new.diff +++ b/tests/test_new.diff @@ -416,4 +416,22 @@ index 0000000..a6c6cb0 + TODO fill this with something useful + */ +} -+ \ No newline at end of file ++ +diff --git a/tests/Makefile b/tests/Makefile +new file mode 100644 +index 0000000..2996176 +--- /dev/null ++++ b/tests/Makefile +@@ -0,0 +1,12 @@ ++# TODO change name. ++NAME = asm ++ ++# TODO source files must be explicitly named. ++SRC = $(shell find mandatory/src -name "*.asm") ++OBJ = $(patsubst src/%.asm, obj/%.o, $(SRC)) ++.PHONY: all ++all: $(NAME) ++$(NAME): $(OBJ) ++ # TODO create the directory. ++ $(AR) rc $@ $(OBJ) ++ diff --git a/tests/test_todo_parser.py b/tests/test_todo_parser.py index e157993..440d0e7 100644 --- a/tests/test_todo_parser.py +++ b/tests/test_todo_parser.py @@ -75,6 +75,9 @@ def test_scss_issues(self): def test_twig_issues(self): self.assertEqual(count_issues_for_file_type(self.raw_issues, 'twig'), 2) + def test_makefile_issues(self): + self.assertEqual(count_issues_for_file_type(self.raw_issues, 'makefile'), 3) + def test_md_issues(self): self.assertEqual(count_issues_for_file_type(self.raw_issues, 'markdown'), 8) @@ -159,6 +162,9 @@ def test_scss_issues(self): def test_twig_issues(self): self.assertEqual(count_issues_for_file_type(self.raw_issues, 'twig'), 2) + def test_makefile_issues(self): + self.assertEqual(count_issues_for_file_type(self.raw_issues, 'makefile'), 3) + def test_md_issues(self): self.assertEqual(count_issues_for_file_type(self.raw_issues, 'markdown'), 8)