[vlc-commits] commit: python: handle non-doxygen comments (Olivier Aubert )

git at videolan.org git at videolan.org
Tue Apr 20 17:33:01 CEST 2010


vlc/python | branch: master | Olivier Aubert <olivier.aubert at liris.cnrs.fr> | Tue Apr 20 16:27:37 2010 +0200| [033a56d8643dd7d4a519060fcb03ae7a6b625409] | committer: Olivier Aubert 

python: handle non-doxygen comments

> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=033a56d8643dd7d4a519060fcb03ae7a6b625409
---

 generate.py |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/generate.py b/generate.py
index 16f2350..42ea009 100755
--- a/generate.py
+++ b/generate.py
@@ -145,6 +145,7 @@ class Parser(object):
 
         f=open(name, 'r')
         accumulator=''
+        comment=None
         for l in f:
             # Note: lstrip() should not be necessary, but there is 1 badly
             # formatted comment in vlc1.0.0 includes
@@ -156,7 +157,16 @@ class Parser(object):
                 continue
 
             l=l.strip()
-            if l.startswith('/*') or l.endswith('*/'):
+            if l.startswith('/*'):
+                # Simple comment start
+                comment=l[2:]
+                continue
+            elif l.endswith('*/'):
+                comment=None
+                continue
+            elif comment is not None:
+                # We are in a comment
+                comment += l
                 continue
 
             if (l.startswith('typedef enum') or l.startswith('enum')) and not l.endswith(';'):
@@ -184,9 +194,12 @@ class Parser(object):
                     else:
                         if l:
                             values.append( (l, str(i)) )
-                comment=comment.replace('@{', '').replace('@see', 'See').replace('\ingroup', '')
+                if comment is None:
+                    comment=""
+                else:
+                    comment=comment.replace('@{', '').replace('@see', 'See').replace('\ingroup', '')
                 yield (typ, name.strip(), values, comment)
-                comment=''
+                comment=None
                 continue
 
             # Special case, used only for libvlc_events.h
@@ -218,13 +231,16 @@ class Parser(object):
                         else:
                             if l:
                                 values.append( (l, str(i)) )
-                comment=comment.replace('@{', '').replace('@see', 'See').replace('\ingroup', '')
+                if comment is None:
+                    comment=""
+                else:
+                    comment=comment.replace('@{', '').replace('@see', 'See').replace('\ingroup', '')
                 if name is None:
                     name="libvlc_enum_t"
                 else:
                     name=name.strip()
                 yield (typ, name, values, comment)
-                comment=''
+                comment=None
                 continue
 
     def parse_include(self, name):



More information about the vlc-commits mailing list