From 38a8ea50a44c057f4245668a024d5e3396aad852 Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Thu, 8 Oct 2020 09:28:11 -0400 Subject: [PATCH 1/3] catching ref typos Signed-off-by: Alyssa Wilk --- tools/code_format/check_format.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index 398f694730aa..f614ea4ccd3a 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -112,6 +112,7 @@ VERSION_HISTORY_NEW_LINE_REGEX = re.compile("\* ([a-z \-_]+): ([a-z:`]+)") VERSION_HISTORY_SECTION_NAME = re.compile("^[A-Z][A-Za-z ]*$") RELOADABLE_FLAG_REGEX = re.compile(".*(.)(envoy.reloadable_features.[^ ]*)\s.*") +INVALID_REFLINK = re.compile(".* ref:.*") # Check for punctuation in a terminal ref clause, e.g. # :ref:`panic mode. ` REF_WITH_PUNCTUATION_REGEX = re.compile(".*\. <[^<]*>`\s*") @@ -447,6 +448,10 @@ def reportError(message): next_word_to_check = '' # first word after : prior_line = '' + invalid_reflink_match = INVALID_REFLINK.match(line) + if invalid_reflink_match: + reportError("Found text \" ref:\". This should probably be \" :ref:\"\n%s" % line) + # make sure flags are surrounded by ``s flag_match = RELOADABLE_FLAG_REGEX.match(line) if flag_match: From f639c34cb05fc9012764b3fb345bc9debce7ba7c Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Thu, 8 Oct 2020 13:23:42 -0400 Subject: [PATCH 2/3] ticks Signed-off-by: Alyssa Wilk --- tools/code_format/check_format.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index f614ea4ccd3a..7b984aac2d35 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -111,7 +111,7 @@ PROTO_VALIDATION_STRING = re.compile(r'\bmin_bytes\b') VERSION_HISTORY_NEW_LINE_REGEX = re.compile("\* ([a-z \-_]+): ([a-z:`]+)") VERSION_HISTORY_SECTION_NAME = re.compile("^[A-Z][A-Za-z ]*$") -RELOADABLE_FLAG_REGEX = re.compile(".*(.)(envoy.reloadable_features.[^ ]*)\s.*") +RELOADABLE_FLAG_REGEX = re.compile(".*(..)(envoy.reloadable_features.[^ ]*)\s.*") INVALID_REFLINK = re.compile(".* ref:.*") # Check for punctuation in a terminal ref clause, e.g. # :ref:`panic mode. ` @@ -455,8 +455,8 @@ def reportError(message): # make sure flags are surrounded by ``s flag_match = RELOADABLE_FLAG_REGEX.match(line) if flag_match: - if not flag_match.groups()[0].startswith('`'): - reportError("Flag `%s` should be enclosed in back ticks" % flag_match.groups()[1]) + if not flag_match.groups()[0].startswith(' `'): + reportError("Flag `%s` should be enclosed in a single set of back ticks" % flag_match.groups()[1]) if line.startswith("* "): if not endsWithPeriod(prior_line): From e7864f41a991839b7b6650ca6c539953dabee989 Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Thu, 8 Oct 2020 13:41:36 -0400 Subject: [PATCH 3/3] format Signed-off-by: Alyssa Wilk --- tools/code_format/check_format.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index 7b984aac2d35..49126f75d3f8 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -456,7 +456,8 @@ def reportError(message): flag_match = RELOADABLE_FLAG_REGEX.match(line) if flag_match: if not flag_match.groups()[0].startswith(' `'): - reportError("Flag `%s` should be enclosed in a single set of back ticks" % flag_match.groups()[1]) + reportError("Flag `%s` should be enclosed in a single set of back ticks" % + flag_match.groups()[1]) if line.startswith("* "): if not endsWithPeriod(prior_line):