From 3a94d6926403ac1f55a9d5723f6b07486f35060b Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Fri, 6 Oct 2017 08:57:01 -0400 Subject: [PATCH] doc parse two lines for getting the context So that signatures can get parsed when they are split like: PG::RecoveryState::RepWaitBackfillReserved::react( const RemoteReservationCanceled &evt) Signed-off-by: Alfredo Deza (cherry picked from commit 9e2a52ccec4a5c833dd861ae528d52efbc0f9e5f) --- doc/scripts/gen_state_diagram.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/doc/scripts/gen_state_diagram.py b/doc/scripts/gen_state_diagram.py index 14017fac3f1ef..fccde26295c4c 100755 --- a/doc/scripts/gen_state_diagram.py +++ b/doc/scripts/gen_state_diagram.py @@ -82,14 +82,22 @@ class StateMachineRenderer(object): ) def read_input(self, input_lines): + previous_line = None for line in input_lines: self.get_state(line) self.get_event(line) - self.get_context(line) - - def get_context(self, line): - match = re.search(r"(\w+::)*::(?P\w+)::\w+\(const (?P\w+)", - line) + # pass two lines at a time to get the context so that regexes can + # match on split signatures + self.get_context(line, previous_line) + previous_line = line + + def get_context(self, line, previous_line): + match = re.search(r"(\w+::)*::(?P\w+)::\w+\(const (?P\w+)", line) + if match is None and previous_line is not None: + # it is possible that we need to match on the previous line as well, so join + # them to make them one line and try and get this matching + joined_line = ' '.join([previous_line, line]) + match = re.search(r"(\w+::)*::(?P\w+)::\w+\(\s*const (?P\w+)", joined_line) if match is not None: self.context.append((match.group('tag'), self.context_depth, match.group('event'))) if '{' in line: -- 2.39.5