From 3765d0a55e5b08ecb685d38f46c0ca9e5bdf6f84 Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Mon, 2 Aug 2021 16:08:53 -0400 Subject: [PATCH 1/2] tools: format checks for backticks Signed-off-by: Alyssa Wilk --- docs/root/version_history/current.rst | 6 +++--- tools/docs/rst_check.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/root/version_history/current.rst b/docs/root/version_history/current.rst index 243facceaed48..90864ca3005ae 100644 --- a/docs/root/version_history/current.rst +++ b/docs/root/version_history/current.rst @@ -21,7 +21,7 @@ Minor Behavior Changes can be reverted by setting runtime guard ``correct_scheme_and_xfp`` to false. * http: set the default :ref:`lazy headermap threshold ` to 3, which defines the minimal number of headers in a request/response/trailers required for using a - dictionary in addition to the list. Setting the `envoy.http.headermap.lazy_map_min_size` runtime + dictionary in addition to the list. Setting the ``envoy.http.headermap.lazy_map_min_size`` runtime feature to a non-negative number will override the default value. * listener: added the :ref:`enable_reuse_port ` field and changed the default for reuse_port from false to true, as the feature is now well @@ -29,7 +29,7 @@ Minor Behavior Changes restart, as otherwise the change would not be backwards compatible between restarts. This means that hot restarting on to a new binary will retain the default of false until the binary undergoes a full restart. To retain the previous behavior, either explicitly set the new configuration - field to false, or set the runtime feature flag `envoy.reloadable_features.listener_reuse_port_default_enabled` + field to false, or set the runtime feature flag ``envoy.reloadable_features.listener_reuse_port_default_enabled`` to false. As part of this change, the use of reuse_port for TCP listeners on both macOS and Windows has been disabled due to suboptimal behavior. See the field documentation for more information. @@ -38,7 +38,7 @@ Bug Fixes --------- *Changes expected to improve the state of the world and are unlikely to have negative effects* -* access log: fix `%UPSTREAM_CLUSTER%` when used in http upstream access logs. Previously, it was always logging as an unset value. +* access log: fix ``%UPSTREAM_CLUSTER%`` when used in http upstream access logs. Previously, it was always logging as an unset value. * cluster: delete pools when they're idle to fix unbounded memory use when using PROXY protocol upstream with tcp_proxy. This behavior can be temporarily reverted by setting the ``envoy.reloadable_features.conn_pool_delete_when_idle`` runtime guard to false. * xray: fix the AWS X-Ray tracer bug where span's error, fault and throttle information was not reported properly as per the `AWS X-Ray documentation `_. Before this fix, server error was reported under 'annotations' section of the segment data. diff --git a/tools/docs/rst_check.py b/tools/docs/rst_check.py index 47bad1aa123a6..d918758f302a1 100644 --- a/tools/docs/rst_check.py +++ b/tools/docs/rst_check.py @@ -9,6 +9,10 @@ RELOADABLE_FLAG_REGEX = re.compile(r".*(...)(envoy.reloadable_features.[^ ]*)\s.*") VERSION_HISTORY_NEW_LINE_REGEX = re.compile(r"\* ([a-z \-_]+): ([a-z:`]+)") VERSION_HISTORY_SECTION_NAME = re.compile(r"^[A-Z][A-Za-z ]*$") +# Make sure backticks come in pairs. +# Exceptions: reflinks (ref:`` where the backtick won't be preceded by a space +# links `title `_ where the _ is checked for in the regex. +BAD_TICKS_REGEX = re.compile(r".* `[^`].*`[^_]") class CurrentVersionFile(object): @@ -43,8 +47,13 @@ def check_flags(self, line: str) -> list: return ([f"Flag {flag_match.groups()[1]} should be enclosed in double back ticks"] if flag_match and not flag_match.groups()[0].startswith(' ``') else []) + def check_ticks(self, line: str) -> list: + ticks_match = BAD_TICKS_REGEX.match(line) + return ([f"Backticks should come in pairs (except for links and reflinks): {line}"] + if ticks_match else []) + def check_line(self, line: str) -> list: - errors = self.check_reflink(line) + self.check_flags(line) + errors = self.check_reflink(line) + self.check_flags(line) + self.check_ticks(line) if line.startswith("* "): errors += self.check_list_item(line) elif not line: From 3367234069e31ea8dbeffb5c9b6d59d8552e883a Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Tue, 3 Aug 2021 13:01:07 -0400 Subject: [PATCH 2/2] working around fragile test Signed-off-by: Alyssa Wilk --- tools/docs/rst_check.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/docs/rst_check.py b/tools/docs/rst_check.py index d918758f302a1..c06d264c2691a 100644 --- a/tools/docs/rst_check.py +++ b/tools/docs/rst_check.py @@ -53,7 +53,9 @@ def check_ticks(self, line: str) -> list: if ticks_match else []) def check_line(self, line: str) -> list: - errors = self.check_reflink(line) + self.check_flags(line) + self.check_ticks(line) + errors = self.check_reflink(line) + self.check_flags(line) + if RELOADABLE_FLAG_REGEX.match(line): + errors += self.check_ticks(line) if line.startswith("* "): errors += self.check_list_item(line) elif not line: