From 4bce59d9635088c3ba1332029f7bedf9cc1b64ed Mon Sep 17 00:00:00 2001 From: Victor Toso Date: Fri, 22 Apr 2022 21:23:43 +0200 Subject: [PATCH] scripts: apibuild: factor out comment cleaning So we can use for comments that are being hold in helper variables. Signed-off-by: Victor Toso Reviewed-by: Andrea Bolognani --- scripts/apibuild.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/apibuild.py b/scripts/apibuild.py index 491c0e1f0d..4648a0e516 100755 --- a/scripts/apibuild.py +++ b/scripts/apibuild.py @@ -733,15 +733,18 @@ class CParser: line = line.replace('*', '', 1) return line - def cleanupComment(self): - if not isinstance(self.comment, str): - return - # remove the leading * on multi-line comments - lines = self.comment.splitlines(True) + def cleanup_code_comment(self, comment: str) -> str: + if not isinstance(comment, str) or comment == "": + return "" + + lines = comment.splitlines(True) com = "" for line in lines: com = com + self.strip_lead_star(line) - self.comment = com.strip() + return com.strip() + + def cleanupComment(self): + self.comment = self.cleanup_code_comment(self.comment) def parseComment(self, token): com = token[1]