[gobject-introspection] [giscanner] Parse multiline gtk-doc comments



commit 669752977abfc8f7abb0b99bd65e28a97db5d315
Author: Johan Dahlin <johan gnome org>
Date:   Mon May 31 16:13:45 2010 -0300

    [giscanner] Parse multiline gtk-doc comments

 giscanner/annotationparser.py             |   12 ++++++++++--
 tests/scanner/annotation-1.0-expected.gir |    4 ++--
 tests/scanner/annotation.c                |    6 ++++--
 3 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index ef60179..85237cd 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -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):
diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir
index ed3c3b9..3191e39 100644
--- a/tests/scanner/annotation-1.0-expected.gir
+++ b/tests/scanner/annotation-1.0-expected.gir
@@ -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>
diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c
index 29e8b37..9795263 100644
--- a/tests/scanner/annotation.c
+++ b/tests/scanner/annotation.c
@@ -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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]