]> xenbits.xensource.com Git - libvirt.git/commitdiff
scripts: apibuild: factor out comment cleaning
authorVictor Toso <victortoso@redhat.com>
Fri, 22 Apr 2022 19:23:43 +0000 (21:23 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Tue, 26 Apr 2022 15:54:30 +0000 (17:54 +0200)
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>
scripts/apibuild.py

index 491c0e1f0d330a5798ea9aa7d8f7418f40655cc1..4648a0e516856ecf95597eda403d45272cafe1f0 100755 (executable)
@@ -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]