From 8c9e1feab1dfe5083bdd2cfbb79631065f5cd648 Mon Sep 17 00:00:00 2001 From: sdilts Date: Thu, 19 Mar 2020 11:54:49 -0600 Subject: [PATCH] Improve Lispify-ing comments + don't remove '*' chars in the middle of comments + Remove spurious whitespace at the beginning of each line, but conserve indentation after that --- cl_bindgen/processfile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cl_bindgen/processfile.py b/cl_bindgen/processfile.py index e66a5dd..0e887a0 100644 --- a/cl_bindgen/processfile.py +++ b/cl_bindgen/processfile.py @@ -13,9 +13,13 @@ # the pip version of clang doesn't have the comment functions, # so define _output_comment accordingly if hasattr(clang.Cursor, 'raw_comment'): + import re + + doc_decorator_re = re.compile("^\s*[*/]* ?",flags=re.MULTILINE) + def _lispify_comment(comment): comment = comment.replace('"', '\\"') - return comment.replace('*','').replace('/','').strip() + return re.sub(doc_decorator_re, '', comment).strip() def _output_comment(cursor, output, before='', after=''): comment = cursor.raw_comment