scripts: apibuild: factor out comment cleaning

So we can use for comments that are being hold in helper variables.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Victor Toso 2022-04-22 21:23:43 +02:00 committed by Andrea Bolognani
parent 034600e601
commit 4bce59d963
1 changed files with 9 additions and 6 deletions

View File

@ -733,15 +733,18 @@ class CParser:
line = line.replace('*', '', 1) line = line.replace('*', '', 1)
return line return line
def cleanupComment(self): def cleanup_code_comment(self, comment: str) -> str:
if not isinstance(self.comment, str): if not isinstance(comment, str) or comment == "":
return return ""
# remove the leading * on multi-line comments
lines = self.comment.splitlines(True) lines = comment.splitlines(True)
com = "" com = ""
for line in lines: for line in lines:
com = com + self.strip_lead_star(line) 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): def parseComment(self, token):
com = token[1] com = token[1]