diff --git a/tools/check.py b/tools/check.py index f298d97e21fb8967855759a330abd0bf882f4a38..62eaf1e22b8b058261e6a8681b6063c85211326b 100755 --- a/tools/check.py +++ b/tools/check.py @@ -141,7 +141,7 @@ class MarkdownValidator(object): for h in missing_headings: logging.error("In {0}: " "Header section is missing expected " - "row {1}".format(self.filename, h)) + "row '{1}'".format(self.filename, h)) return has_hrs and all(test_headers) and only_headers @@ -371,9 +371,9 @@ class TopicPageValidator(MarkdownValidator): if node_tests is False: logging.error( "In {0}: " - "Learning Objectives should not be empty.".format( - self.filename)) - + "Page should contain a blockquoted section with level 2 " + "title 'Learning Objectives'. Section should not " + "be empty.".format(self.filename)) return node_tests def _validate_has_no_headings(self): @@ -385,17 +385,13 @@ class TopicPageValidator(MarkdownValidator): if len(heading_nodes) == 0: return True + # Individual heading msgs are logged by validate_section_heading_order logging.error( "In {0}: " "The topic page should not have sub-headings " "outside of special blocks. " "If a topic needs sub-headings, " "it should be broken into multiple topics.".format(self.filename)) - for n in heading_nodes: - logging.warning( - "In {0}: " - "The following sub-heading should be removed: {1}".format( - self.filename, n.strings[0])) return False def _run_tests(self): @@ -433,10 +429,10 @@ class ReferencePageValidator(MarkdownValidator): glossary_keyword = glossary_entry[0] if len(glossary_entry) < 2: logging.error( - "In {0}:" - "Glossary entry '{1}' must have at least two lines- " - "a term and a definition.".format( - glossary_keyword, self.filename)) + "In {0}: " + "Glossary entry '{1}' must have at least two lines- " + "a term and a definition.".format( + self.filename, glossary_keyword)) return False entry_is_valid = True @@ -444,20 +440,20 @@ class ReferencePageValidator(MarkdownValidator): if line_index == 1: if not re.match("^: ", line): logging.error( - "In {0}:" - "At glossary entry '{1}' " - "First line of definition must " - "start with ': '.".format( - glossary_keyword, self.filename)) + "In {0}: " + "At glossary entry '{1}' " + "First line of definition must " + "start with ': '.".format( + self.filename, glossary_keyword)) entry_is_valid = False elif line_index > 1: if not re.match("^ ", line): logging.error( - "In {0}:" - "At glossary entry '{1}' " - "Subsequent lines of definition must " - "start with ' '.".format( - glossary_keyword, self.filename)) + "In {0}: " + "At glossary entry '{1}' " + "Subsequent lines of definition must " + "start with ' '.".format( + self.filename, glossary_keyword, )) entry_is_valid = False return entry_is_valid diff --git a/tools/test_check.py b/tools/test_check.py index 0451c8444d914aca6ab9fe2635575f49814dfd34..99cf9457792f250e9b2dd89d7ce9174084a02d07 100644 --- a/tools/test_check.py +++ b/tools/test_check.py @@ -295,6 +295,14 @@ minutes: not a number ---""") self.assertFalse(validator._validate_doc_headers()) + def test_topic_page_should_have_no_headings(self): + """Requirement according to spec; may be relaxed in future""" + validator = self._create_validator(""" +## Heading that should not be present + +Some text""") + self.assertFalse(validator._validate_has_no_headings()) + def test_sample_file_passes_validation(self): sample_validator = self.VALIDATOR(self.SAMPLE_FILE) res = sample_validator.validate()