From eb4942072806207edf6f5fef363747866ec112a3 Mon Sep 17 00:00:00 2001 From: davemachado Date: Sun, 11 Mar 2018 22:04:14 -0400 Subject: [PATCH] Add Section Header check to CI --- build/validate_format.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build/validate_format.py b/build/validate_format.py index 18d2c134..5666799b 100755 --- a/build/validate_format.py +++ b/build/validate_format.py @@ -18,6 +18,9 @@ index_cors = 4 index_link = 5 errors = [] +title_links = [] +anchor_re = re.compile('###\s(.+)') +section_title_re = re.compile('\*\s\[(.*)\]') def add_error(line_num, message): @@ -107,11 +110,16 @@ def check_format(filename): num_in_category = min_entries_per_section + 1 category = "" category_line = 0 - anchor_re = re.compile('###\s\S+') for line_num, line in enumerate(lines): + if section_title_re.match(line): + title_links.append(section_title_re.match(line).group(1)) # check each section for the minimum number of entries if line.startswith(anchor): - if not anchor_re.match(line): + match = anchor_re.match(line) + if match: + if match.group(1) not in title_links: + add_error(line_num, "section header ({}) not added as a title link".format(match.group(1))) + else: add_error(line_num, "section header is not formatted correctly") if num_in_category < min_entries_per_section: add_error(category_line, "{} section does not have the minimum {} entries (only has {})".format(