[giscanner] Parse multiline gtk-doc comments
authorJohan Dahlin <johan@gnome.org>
Mon, 31 May 2010 19:13:45 +0000 (16:13 -0300)
committerJohan Dahlin <johan@gnome.org>
Mon, 31 May 2010 19:13:45 +0000 (16:13 -0300)
giscanner/annotationparser.py
tests/scanner/annotation-1.0-expected.gir
tests/scanner/annotation.c

index ef60179..85237cd 100644 (file)
@@ -201,15 +201,23 @@ class AnnotationParser(object):
             block_name, block_options = block_header, {}
         block = DocBlock(block_name, block_options)
         comment_lines = []
+        parse_parameters = True
+        canon_name = ''
         for line in comment[pos+1:].split('\n'):
             line = line.lstrip()
             line = line[2:].strip() # Skip ' *'
             if not line:
+                if parse_parameters:
+                    parse_parameters = False
                 continue
             if line.startswith('@'):
                 line = line[1:]
             elif not ': ' in line:
-                comment_lines.append(line)
+                if parse_parameters and line:
+                    if canon_name != '' and canon_name in block.tags:
+                        block.tags[canon_name].comment += ' ' + line
+                else:
+                    comment_lines.append(line)
                 continue
             tag_name, value = self._split_tag_namevalue(line)
             canon_name = tag_name.lower()
@@ -240,7 +248,7 @@ class AnnotationParser(object):
         tag.value = value
         options, rest = self._parse_options(tag.value)
         tag.options = options
-        tag.comment = rest
+        tag.comment = rest or ''
         return tag
 
     def _parse_options(self, value):
index ed3c3b9..3191e39 100644 (file)
@@ -307,7 +307,7 @@ intentionally similar example to gtk_container_get_children">
         <parameters>
           <parameter name="nums"
                      transfer-ownership="none"
-                     doc="Sequence of numbers">
+                     doc="Sequence of numbers that are zero-terminated">
             <array zero-terminated="0" length="2" c:type="int*">
               <type name="int"/>
             </array>
@@ -326,7 +326,7 @@ intentionally similar example to gtk_container_get_children">
         <parameters>
           <parameter name="nums"
                      transfer-ownership="none"
-                     doc="Sequence of numbers">
+                     doc="Sequence of numbers that are zero-terminated">
             <array length="2" c:type="int*">
               <type name="int"/>
             </array>
index 29e8b37..9795263 100644 (file)
@@ -383,7 +383,8 @@ annotation_object_compute_sum  (AnnotationObject *object,
 /**
  * annotation_object_compute_sum_n:
  * @object: a #GObject
- * @nums: (array length=n_nums zero-terminated=0): Sequence of numbers
+ * @nums: (array length=n_nums zero-terminated=0): Sequence of
+ *   numbers that are zero-terminated
  * @n_nums: Length of number array
  *
  * Test taking an array with length parameter
@@ -399,7 +400,8 @@ annotation_object_compute_sum_n(AnnotationObject *object,
 /**
  * annotation_object_compute_sum_nz:
  * @object: a #AnnotationObject
- * @nums: (array length=n_nums zero-terminated=1): Sequence of numbers
+ * @nums: (array length=n_nums zero-terminated=1): Sequence of numbers that
+ * are zero-terminated
  * @n_nums: Length of number array
  *
  * Test taking a zero-terminated array with length parameter