[PATCH v3 28/30] scripts: apibuild: factor out comment cleaning

Victor Toso victortoso at redhat.com
Wed Apr 20 19:08:17 UTC 2022


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

Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 scripts/apibuild.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/scripts/apibuild.py b/scripts/apibuild.py
index ec10931151..151eba37e6 100755
--- a/scripts/apibuild.py
+++ b/scripts/apibuild.py
@@ -789,15 +789,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(self.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]
-- 
2.35.1



More information about the libvir-list mailing list