[gobject-introspection] giscanner: extract tag values



commit 839e4f10a6b291a261c200484ff05ec44a31d93e
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Thu Jul 25 17:22:21 2013 +0200

    giscanner: extract tag values

 gir/gio-2.0.c                                      |    4 +-
 gir/glib-2.0.c                                     |    2 +-
 giscanner/annotationparser.py                      |   63 +++++++++++++++---
 giscanner/maintransformer.py                       |   26 ++-----
 .../gi/annotation_get_value_func.xml               |    2 +-
 .../annotationparser/gi/annotation_ref_func.xml    |    2 +-
 .../annotationparser/gi/annotation_rename_to.xml   |    2 +-
 .../gi/annotation_set_value_func.xml               |    2 +-
 .../annotationparser/gi/annotation_transfer.xml    |    2 +-
 .../annotationparser/gi/annotation_type.xml        |    2 +-
 .../annotationparser/gi/annotation_unref_func.xml  |    2 +-
 .../annotationparser/gi/annotation_value.xml       |    2 +-
 .../annotationparser/gi/annotation_virtual.xml     |    2 +-
 .../annotationparser/gi/parameter_varargs.xml      |   15 +++--
 .../annotationparser/gi/syntax_nested_tags.xml     |    2 +-
 .../scanner/annotationparser/gi/tag_deprecated.xml |    9 ++-
 tests/scanner/annotationparser/gi/tag_returns.xml  |    4 +-
 tests/scanner/annotationparser/gi/tag_since.xml    |   12 ++--
 .../scanner/annotationparser/gi/tag_stability.xml  |   10 ++--
 .../annotationparser/gtkdoc/bugs/tester.c.xml      |    2 +-
 .../annotationparser/gtkdoc/gobject/giface.c.xml   |    2 +-
 .../annotationparser/gtkdoc/gobject/gobject.c.xml  |    8 +-
 .../annotationparser/gtkdoc/gobject/gobject.h.xml  |    2 +-
 tests/scanner/annotationparser/test_parser.py      |    8 ++-
 tests/scanner/annotationparser/test_patterns.py    |   69 ++++++++++++++++++++
 25 files changed, 185 insertions(+), 71 deletions(-)
---
diff --git a/gir/gio-2.0.c b/gir/gio-2.0.c
index e41cb3b..5da24c2 100644
--- a/gir/gio-2.0.c
+++ b/gir/gio-2.0.c
@@ -2162,7 +2162,7 @@
  * 'settings-schema' property if you wish to pass in a
  * #GSettingsSchema.
  *
- * Deprecated: 2.32:Use the 'schema-id' property instead.  In a future version, this property may instead 
refer to a #GSettingsSchema.
+ * Deprecated: 2.32: Use the 'schema-id' property instead.  In a future version, this property may instead 
refer to a #GSettingsSchema.
  */
 
 
@@ -11456,7 +11456,7 @@
  * Now there is #GActionMap for that.
  *
  * Since: 2.28
- * Deprecated: 2.32:Use the #GActionMap interface instead.  Never ever mix use of this API with use of 
#GActionMap on the same @application or things will go very badly wrong.  This function is known to introduce 
buggy behaviour (ie: signals not emitted on changes to the action group), so you should really use 
#GActionMap instead.
+ * Deprecated: 2.32: Use the #GActionMap interface instead.  Never ever mix use of this API with use of 
#GActionMap on the same @application or things will go very badly wrong.  This function is known to introduce 
buggy behaviour (ie: signals not emitted on changes to the action group), so you should really use 
#GActionMap instead.
  */
 
 
diff --git a/gir/glib-2.0.c b/gir/glib-2.0.c
index aeb682d..12e79f4 100644
--- a/gir/glib-2.0.c
+++ b/gir/glib-2.0.c
@@ -3379,7 +3379,7 @@
  * before the spelling was fixed in GLib 2.30.  It is kept here for
  * compatibility reasons.
  *
- * Deprecated: 2.30:Use G_IO_FLAG_IS_WRITABLE instead.
+ * Deprecated: 2.30: Use G_IO_FLAG_IS_WRITABLE instead.
  */
 
 
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 1828c74..26e001e 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -459,6 +459,36 @@ MULTILINE_ANNOTATION_CONTINUATION_RE = re.compile(
     ''',
     re.UNICODE | re.VERBOSE)
 
+# Pattern matching value and description fields for TAG_DEPRECATED & TAG_SINCE tags.
+TAG_VALUE_VERSION_RE = re.compile(
+    r'''
+    ^                                                    # start
+    \s*                                                  # 0 or more whitespace characters
+    (?P<value>([0-9\.])*)                                # value
+    \s*                                                  # 0 or more whitespace characters
+    (?P<delimiter>:?)                                    # delimiter
+    \s*                                                  # 0 or more whitespace characters
+    (?P<description>.*?)                                 # description
+    \s*                                                  # 0 or more whitespace characters
+    $                                                    # end
+    ''',
+    re.UNICODE | re.VERBOSE)
+
+# Pattern matching value and description fields for TAG_STABILITY tags.
+TAG_VALUE_STABILITY_RE = re.compile(
+    r'''
+    ^                                                    # start
+    \s*                                                  # 0 or more whitespace characters
+    (?P<value>(stable|unstable|private|internal)?)       # value
+    \s*                                                  # 0 or more whitespace characters
+    (?P<delimiter>:?)                                    # delimiter
+    \s*                                                  # 0 or more whitespace characters
+    (?P<description>.*?)                                 # description
+    \s*                                                  # 0 or more whitespace characters
+    $                                                    # end
+    ''',
+    re.UNICODE | re.VERBOSE | re.IGNORECASE)
+
 
 class DocOption(object):
 
@@ -645,13 +675,19 @@ class GtkDocTag(object):
                 return fmt % (option, value)
             else:
                 return fmt2 % (option, )
+        serialized = ''
         annotations = []
         for ann_name, options in self.annotations.items():
             annotations.append(serialize_one(ann_name, options, '(%s %s)', '(%s)'))
         if annotations:
-            return ' '.join(annotations) + ': '
-        else:
-            return self.value
+            serialized += ' '.join(annotations)
+        if self.value and annotations:
+            serialized += ': '
+        if self.value:
+            serialized += self.value
+        if self.description and (annotations or self.value):
+            serialized += ': '
+        return serialized
 
     def to_gtk_doc_param(self):
         return '@%s: %s%s' % (self.name, self._get_gtk_doc_value(), self.description)
@@ -1185,7 +1221,7 @@ class GtkDocCommentBlockParser(object):
 
                     tag = GtkDocTag(tag_name.lower())
                     tag.position = position
-                    tag.value = tag_description
+
                     if tag_annotations:
                         if tag_name.lower() == TAG_ATTRIBUTES:
                             tag.annotations = self.parse_annotations(tag, tag_annotations)
@@ -1193,6 +1229,19 @@ class GtkDocCommentBlockParser(object):
                             warn("annotations not supported for tag '%s:'." %
                                  (tag_name, ),
                                  position)
+
+                    if tag_name.lower() in [TAG_DEPRECATED, TAG_SINCE]:
+                        result = TAG_VALUE_VERSION_RE.match(tag_description)
+                        tag.value = result.group('value')
+                        tag.description = result.group('description')
+                    elif tag_name.lower() == TAG_STABILITY:
+                        result = TAG_VALUE_STABILITY_RE.match(tag_description)
+                        tag.value = result.group('value').capitalize()
+                        tag.description = result.group('description')
+                    elif tag_name.lower() in GI_ANN_TAGS:
+                        tag.value = tag_description
+                        tag.description = ''
+
                     comment_block.tags[tag_name.lower()] = tag
                     current_tag = tag
                     continue
@@ -1216,11 +1265,7 @@ class GtkDocCommentBlockParser(object):
             elif in_part == PART_TAGS:
                 self._validate_multiline_annotation_continuation(line, original_line,
                                                                  column_offset, position)
-                # Append to tag description.
-                if current_tag.name.lower() in [TAG_RETURNS, TAG_RETURN_VALUE]:
-                    current_tag.description += ' ' + line.strip()
-                else:
-                    current_tag.value += ' ' + line.strip()
+                current_tag.description += ' ' + line.strip()
                 continue
 
         ########################################################################
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 6ffec2f..af9a0a1 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -595,30 +595,20 @@ class MainTransformer(object):
 
         since_tag = block.tags.get(TAG_SINCE)
         if since_tag is not None:
-            node.version = since_tag.value
+            if since_tag.value:
+                node.version = since_tag.value
 
         deprecated_tag = block.tags.get(TAG_DEPRECATED)
         if deprecated_tag is not None:
-            value = deprecated_tag.value
-            if ': ' in value:
-                delimiter = value.find(': ')
-                version = value[:delimiter]
-                desc = value[delimiter + 2:]
-            else:
-                desc = value
-                version = None
-            node.deprecated = desc
-            if version is not None:
-                node.deprecated_version = version
+            if deprecated_tag.value:
+                node.deprecated_version = deprecated_tag.value
+            if deprecated_tag.description:
+                node.deprecated = deprecated_tag.description
 
         stability_tag = block.tags.get(TAG_STABILITY)
         if stability_tag is not None:
-            stability = stability_tag.value.capitalize()
-            if stability in ["Stable", "Unstable", "Private", "Internal"]:
-                node.stability = stability
-            else:
-                message.warn('unknown value "%s" for Stability tag' % (
-                    stability_tag.value), stability_tag.position)
+            if stability_tag.value:
+                node.stability = stability_tag.value
 
         annos_tag = block.tags.get(TAG_ATTRIBUTES)
         if annos_tag is not None:
diff --git a/tests/scanner/annotationparser/gi/annotation_get_value_func.xml 
b/tests/scanner/annotationparser/gi/annotation_get_value_func.xml
index ab71a7d..cfc6428 100644
--- a/tests/scanner/annotationparser/gi/annotation_get_value_func.xml
+++ b/tests/scanner/annotationparser/gi/annotation_get_value_func.xml
@@ -22,7 +22,7 @@
       <tags>
         <tag>
           <name>get value func</name>
-          <description>regress_test_value_get_fundamental_object</description>
+          <value>regress_test_value_get_fundamental_object</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/annotation_ref_func.xml 
b/tests/scanner/annotationparser/gi/annotation_ref_func.xml
index 9d159c1..5f94570 100644
--- a/tests/scanner/annotationparser/gi/annotation_ref_func.xml
+++ b/tests/scanner/annotationparser/gi/annotation_ref_func.xml
@@ -22,7 +22,7 @@
       <tags>
         <tag>
           <name>ref func</name>
-          <description>regress_test_fundamental_object_ref</description>
+          <value>regress_test_fundamental_object_ref</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/annotation_rename_to.xml 
b/tests/scanner/annotationparser/gi/annotation_rename_to.xml
index dc79d18..5d9d3b1 100644
--- a/tests/scanner/annotationparser/gi/annotation_rename_to.xml
+++ b/tests/scanner/annotationparser/gi/annotation_rename_to.xml
@@ -44,7 +44,7 @@
       <tags>
         <tag>
           <name>rename to</name>
-          <description>annotation_object_watch</description>
+          <value>annotation_object_watch</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/annotation_set_value_func.xml 
b/tests/scanner/annotationparser/gi/annotation_set_value_func.xml
index 5418c9c..0164a5b 100644
--- a/tests/scanner/annotationparser/gi/annotation_set_value_func.xml
+++ b/tests/scanner/annotationparser/gi/annotation_set_value_func.xml
@@ -22,7 +22,7 @@
       <tags>
         <tag>
           <name>set value func</name>
-          <description>regress_test_value_set_fundamental_object</description>
+          <value>regress_test_value_set_fundamental_object</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/annotation_transfer.xml 
b/tests/scanner/annotationparser/gi/annotation_transfer.xml
index 511f24d..535a4d2 100644
--- a/tests/scanner/annotationparser/gi/annotation_transfer.xml
+++ b/tests/scanner/annotationparser/gi/annotation_transfer.xml
@@ -160,7 +160,7 @@ without....</description>
       <tags>
         <tag>
           <name>transfer</name>
-          <description>full</description>
+          <value>full</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/annotation_type.xml 
b/tests/scanner/annotationparser/gi/annotation_type.xml
index 16d4531..885b4bc 100644
--- a/tests/scanner/annotationparser/gi/annotation_type.xml
+++ b/tests/scanner/annotationparser/gi/annotation_type.xml
@@ -78,7 +78,7 @@ known by GObject as it's only marked as G_TYPE_POINTER</description>
       <tags>
         <tag>
           <name>type</name>
-          <description>GLib.HashTable(utf8,gint8)</description>
+          <value>GLib.HashTable(utf8,gint8)</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/annotation_unref_func.xml 
b/tests/scanner/annotationparser/gi/annotation_unref_func.xml
index 32bd892..528923b 100644
--- a/tests/scanner/annotationparser/gi/annotation_unref_func.xml
+++ b/tests/scanner/annotationparser/gi/annotation_unref_func.xml
@@ -22,7 +22,7 @@
       <tags>
         <tag>
           <name>unref func</name>
-          <description>regress_test_fundamental_object_unref</description>
+          <value>regress_test_fundamental_object_unref</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/annotation_value.xml 
b/tests/scanner/annotationparser/gi/annotation_value.xml
index e7c7d6f..c5acb4e 100644
--- a/tests/scanner/annotationparser/gi/annotation_value.xml
+++ b/tests/scanner/annotationparser/gi/annotation_value.xml
@@ -22,7 +22,7 @@
       <tags>
         <tag>
          <name>value</name>
-         <description>10000000000UL</description>
+         <value>10000000000UL</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/annotation_virtual.xml 
b/tests/scanner/annotationparser/gi/annotation_virtual.xml
index ae8c3be..e01d993 100644
--- a/tests/scanner/annotationparser/gi/annotation_virtual.xml
+++ b/tests/scanner/annotationparser/gi/annotation_virtual.xml
@@ -39,7 +39,7 @@
       <tags>
         <tag>
           <name>virtual</name>
-          <description>read_fn</description>
+          <value>read_fn</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/parameter_varargs.xml 
b/tests/scanner/annotationparser/gi/parameter_varargs.xml
index 7eb6236..b873de2 100644
--- a/tests/scanner/annotationparser/gi/parameter_varargs.xml
+++ b/tests/scanner/annotationparser/gi/parameter_varargs.xml
@@ -50,11 +50,12 @@ other declarations (which may be documented elsewhere).</description>
         </tag>
         <tag>
           <name>since</name>
-          <description>2.2</description>
+          <value>2.2</value>
         </tag>
         <tag>
           <name>deprecated</name>
-          <description>2.18: Use other_function() instead.</description>
+          <value>2.18</value>
+          <description>Use other_function() instead.</description>
         </tag>
       </tags>
     </docblock>
@@ -155,11 +156,12 @@ other declarations (which may be documented elsewhere).</description>
         </tag>
         <tag>
           <name>since</name>
-          <description>2.2</description>
+          <value>2.2</value>
         </tag>
         <tag>
           <name>deprecated</name>
-          <description>2.18: Use other_function() instead.</description>
+          <value>2.18</value>
+          <description>Use other_function() instead.</description>
         </tag>
       </tags>
     </docblock>
@@ -222,11 +224,12 @@ other declarations (which may be documented elsewhere).</description>
         </tag>
         <tag>
           <name>since</name>
-          <description>2.2</description>
+          <value>2.2</value>
         </tag>
         <tag>
           <name>deprecated</name>
-          <description>2.18: Use other_function() instead.</description>
+          <value>2.18</value>
+          <description>Use other_function() instead.</description>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/syntax_nested_tags.xml 
b/tests/scanner/annotationparser/gi/syntax_nested_tags.xml
index b3eaab5..4ebe0ea 100644
--- a/tests/scanner/annotationparser/gi/syntax_nested_tags.xml
+++ b/tests/scanner/annotationparser/gi/syntax_nested_tags.xml
@@ -35,7 +35,7 @@
       <tags>
         <tag>
           <name>since</name>
-          <description>2.28</description>
+          <value>2.28</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/tag_deprecated.xml 
b/tests/scanner/annotationparser/gi/tag_deprecated.xml
index 2138014..b33509c 100644
--- a/tests/scanner/annotationparser/gi/tag_deprecated.xml
+++ b/tests/scanner/annotationparser/gi/tag_deprecated.xml
@@ -16,7 +16,8 @@
       <tags>
         <tag>
           <name>deprecated</name>
-          <description>0.6: Use something else instead</description>
+          <value>0.6</value>
+          <description>Use something else instead</description>
         </tag>
       </tags>
     </docblock>
@@ -37,7 +38,7 @@
       <tags>
         <tag>
           <name>deprecated</name>
-          <description>0.6</description>
+          <value>0.6</value>
         </tag>
       </tags>
     </docblock>
@@ -61,7 +62,7 @@
       <tags>
         <tag>
           <name>deprecated</name>
-          <description>2.24</description>
+          <value>2.24</value>
         </tag>
       </tags>
     </docblock>
@@ -89,7 +90,7 @@
       <tags>
         <tag>
           <name>deprecated</name>
-          <description>2.0</description>
+          <value>2.0</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/tag_returns.xml 
b/tests/scanner/annotationparser/gi/tag_returns.xml
index 60d3d58..b5643b3 100644
--- a/tests/scanner/annotationparser/gi/tag_returns.xml
+++ b/tests/scanner/annotationparser/gi/tag_returns.xml
@@ -275,7 +275,7 @@ parameter is encountered.</description>
         </tag>
         <tag>
           <name>since</name>
-          <description>1.10</description>
+          <value>1.10</value>
         </tag>
       </tags>
     </docblock>
@@ -326,7 +326,7 @@ parameter is encountered.</description>
         </tag>
         <tag>
           <name>since</name>
-          <description>1.10</description>
+          <value>1.10</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gi/tag_since.xml b/tests/scanner/annotationparser/gi/tag_since.xml
index 4c586e7..e736aba 100644
--- a/tests/scanner/annotationparser/gi/tag_since.xml
+++ b/tests/scanner/annotationparser/gi/tag_since.xml
@@ -16,7 +16,7 @@
       <tags>
         <tag>
           <name>since</name>
-          <description>0.6</description>
+          <value>0.6</value>
         </tag>
       </tags>
     </docblock>
@@ -61,7 +61,7 @@
       <tags>
         <tag>
           <name>since</name>
-          <description>2.24</description>
+          <value>2.24</value>
         </tag>
       </tags>
     </docblock>
@@ -79,7 +79,8 @@
  * test_multiple_tags:
  *
  * Since: 3.0
- * Since: 2.0
+ * Since: 2.0: one of these "Since:"
+ * tags is wrong...
  **/</input>
   <parser>
     <docblock>
@@ -89,13 +90,14 @@
       <tags>
         <tag>
           <name>since</name>
-          <description>2.0</description>
+          <value>2.0</value>
+          <description>one of these "Since:" tags is wrong...</description>
         </tag>
       </tags>
     </docblock>
     <messages>
       <message>5: Warning: Test: multiple 'Since:' tags for identifier 'test_multiple_tags':
- * Since: 2.0
+ * Since: 2.0: one of these "Since:"
    ^</message>
     </messages>
   </parser>
diff --git a/tests/scanner/annotationparser/gi/tag_stability.xml 
b/tests/scanner/annotationparser/gi/tag_stability.xml
index c434e56..27976fd 100644
--- a/tests/scanner/annotationparser/gi/tag_stability.xml
+++ b/tests/scanner/annotationparser/gi/tag_stability.xml
@@ -16,7 +16,7 @@
       <tags>
         <tag>
           <name>stability</name>
-          <description>Stable</description>
+          <value>Stable</value>
         </tag>
       </tags>
     </docblock>
@@ -37,7 +37,7 @@
       <tags>
         <tag>
           <name>stability</name>
-          <description>Unstable</description>
+          <value>Unstable</value>
         </tag>
       </tags>
     </docblock>
@@ -58,7 +58,7 @@
       <tags>
         <tag>
           <name>stability</name>
-          <description>Private</description>
+          <value>Private</value>
         </tag>
       </tags>
     </docblock>
@@ -103,7 +103,7 @@
       <tags>
         <tag>
           <name>stability</name>
-          <description>Private</description>
+          <value>Private</value>
         </tag>
       </tags>
     </docblock>
@@ -131,7 +131,7 @@
       <tags>
         <tag>
           <name>stability</name>
-          <description>Private</description>
+          <value>Private</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gtkdoc/bugs/tester.c.xml 
b/tests/scanner/annotationparser/gtkdoc/bugs/tester.c.xml
index b8aea1a..1197c9b 100644
--- a/tests/scanner/annotationparser/gtkdoc/bugs/tester.c.xml
+++ b/tests/scanner/annotationparser/gtkdoc/bugs/tester.c.xml
@@ -148,7 +148,7 @@ http://bugzilla.gnome.org/show_bug.cgi?id=380824</description>
       <tags>
         <tag>
           <name>since</name>
-          <description>0.1</description>
+          <value>0.1</value>
         </tag>
         <tag>
           <name>returns</name>
diff --git a/tests/scanner/annotationparser/gtkdoc/gobject/giface.c.xml 
b/tests/scanner/annotationparser/gtkdoc/gobject/giface.c.xml
index 65dca48..053b44b 100644
--- a/tests/scanner/annotationparser/gtkdoc/gobject/giface.c.xml
+++ b/tests/scanner/annotationparser/gtkdoc/gobject/giface.c.xml
@@ -122,7 +122,7 @@ or \# or even \  ]]></description>
         </tag>
         <tag>
           <name>since</name>
-          <description>0.1</description>
+          <value>0.1</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gtkdoc/gobject/gobject.c.xml 
b/tests/scanner/annotationparser/gtkdoc/gobject/gobject.c.xml
index 1f61940..7234ed8 100644
--- a/tests/scanner/annotationparser/gtkdoc/gobject/gobject.c.xml
+++ b/tests/scanner/annotationparser/gtkdoc/gobject/gobject.c.xml
@@ -175,7 +175,7 @@ All the internal details go here or not:
         </tag>
         <tag>
           <name>since</name>
-          <description>0.1</description>
+          <value>0.1</value>
         </tag>
       </tags>
     </docblock>
@@ -218,7 +218,7 @@ All the internal details go here or not:
         </tag>
         <tag>
           <name>since</name>
-          <description>0.5</description>
+          <value>0.5</value>
         </tag>
       </tags>
     </docblock>
@@ -266,7 +266,7 @@ complex algorithm (http://en.wikipedia.org/wiki/Algorithm).
       <tags>
         <tag>
           <name>since</name>
-          <description>0.5</description>
+          <value>0.5</value>
         </tag>
       </tags>
     </docblock>
@@ -409,7 +409,7 @@ complex algorithm (http://en.wikipedia.org/wiki/Algorithm).
       <tags>
         <tag>
           <name>since</name>
-          <description>0.1</description>
+          <value>0.1</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/gtkdoc/gobject/gobject.h.xml 
b/tests/scanner/annotationparser/gtkdoc/gobject/gobject.h.xml
index 66627b5..2fb9696 100644
--- a/tests/scanner/annotationparser/gtkdoc/gobject/gobject.h.xml
+++ b/tests/scanner/annotationparser/gtkdoc/gobject/gobject.h.xml
@@ -124,7 +124,7 @@
       <tags>
         <tag>
           <name>since</name>
-          <description>0.1</description>
+          <value>0.1</value>
         </tag>
       </tags>
     </docblock>
diff --git a/tests/scanner/annotationparser/test_parser.py b/tests/scanner/annotationparser/test_parser.py
index c88cc26..98ae787 100644
--- a/tests/scanner/annotationparser/test_parser.py
+++ b/tests/scanner/annotationparser/test_parser.py
@@ -203,8 +203,10 @@ class TestCommentBlock(unittest.TestCase):
                                 parsed += '          </options>\n'
                             parsed += '        </annotation>\n'
                         parsed += '      </annotations>\n'
-                    if tag.description or tag.value:
-                        parsed += '      <description>%s</description>\n' % (tag.description or tag.value, )
+                    if tag.value:
+                        parsed += '      <value>%s</value>\n' % (tag.value, )
+                    if tag.description:
+                        parsed += '      <description>%s</description>\n' % (tag.description, )
                     parsed += '    </tag>\n'
                 parsed += '  </tags>\n'
 
@@ -297,6 +299,8 @@ class TestCommentBlock(unittest.TestCase):
                                 expected += '          </options>\n'
                             expected += '        </annotation>\n'
                         expected += '      </annotations>\n'
+                    if tag.find(ns('{}value')) is not None:
+                        expected += '      <value>%s</value>\n' % (tag.find(ns('{}value')).text, )
                     if tag.find(ns('{}description')) is not None:
                         expected += '      <description>%s</description>\n' % 
(tag.find(ns('{}description')).text, )
                     expected += '    </tag>\n'
diff --git a/tests/scanner/annotationparser/test_patterns.py b/tests/scanner/annotationparser/test_patterns.py
index 17fc197..d121ae6 100644
--- a/tests/scanner/annotationparser/test_patterns.py
+++ b/tests/scanner/annotationparser/test_patterns.py
@@ -33,6 +33,7 @@ against the expected output.
 
 from giscanner.annotationparser import (SECTION_RE, SYMBOL_RE, PROPERTY_RE,
                                         SIGNAL_RE, PARAMETER_RE, TAG_RE,
+                                        TAG_VALUE_VERSION_RE, TAG_VALUE_STABILITY_RE,
                                         COMMENT_END_RE)
 from unittest import (TestCase, main)
 
@@ -539,6 +540,72 @@ tag_tests = [
           'delimiter': ':',
           'description': ''})]
 
+tag_value_version_tests = [
+    (TAG_VALUE_VERSION_RE, ' abc',
+         {'value': '',
+          'delimiter': '',
+          'description': 'abc'}),
+    (TAG_VALUE_VERSION_RE, '5 abc',
+         {'value': '5',
+          'delimiter': '',
+          'description': 'abc'}),
+    (TAG_VALUE_VERSION_RE, '5:abc',
+         {'value': '5',
+          'delimiter': ':',
+          'description': 'abc'}),
+    (TAG_VALUE_VERSION_RE, ' 0.1: abc',
+         {'value': '0.1',
+          'delimiter': ':',
+          'description': 'abc'}),
+    (TAG_VALUE_VERSION_RE, ' 12.10.3698: abc',
+         {'value': '12.10.3698',
+          'delimiter': ':',
+          'description': 'abc'})]
+
+
+tag_value_stability_tests = [
+    (TAG_VALUE_STABILITY_RE, ' abc',
+         {'value': '',
+          'delimiter': '',
+          'description': 'abc'}),
+    (TAG_VALUE_STABILITY_RE, 'stable abc',
+         {'value': 'stable',
+          'delimiter': '',
+          'description': 'abc'}),
+    (TAG_VALUE_STABILITY_RE, 'unstable abc',
+         {'value': 'unstable',
+          'delimiter': '',
+          'description': 'abc'}),
+    (TAG_VALUE_STABILITY_RE, 'private abc',
+         {'value': 'private',
+          'delimiter': '',
+          'description': 'abc'}),
+    (TAG_VALUE_STABILITY_RE, 'internal abc',
+         {'value': 'internal',
+          'delimiter': '',
+          'description': 'abc'}),
+    (TAG_VALUE_STABILITY_RE, 'StAbLe: abc',
+         {'value': 'StAbLe',
+          'delimiter': ':',
+          'description': 'abc'}),
+    (TAG_VALUE_STABILITY_RE, 'uNsTaBlE: abc',
+         {'value': 'uNsTaBlE',
+          'delimiter': ':',
+          'description': 'abc'}),
+    (TAG_VALUE_STABILITY_RE, 'PRIVATE: abc',
+         {'value': 'PRIVATE',
+          'delimiter': ':',
+          'description': 'abc'}),
+    (TAG_VALUE_STABILITY_RE, '  internal  : abc',
+         {'value': 'internal',
+          'delimiter': ':',
+          'description': 'abc'}),
+    (TAG_VALUE_STABILITY_RE, 'xyz: abc',
+         {'value': '',
+          'delimiter': '',
+          'description': 'xyz: abc'})]
+
+
 comment_end_tests = [
     (COMMENT_END_RE, '*/',
          {'description': ''}),
@@ -615,6 +682,8 @@ if __name__ == '__main__':
     create_tests('test_parameter', parameter_tests)
     create_tests('test_tag', tag_tests)
     create_tests('test_comment_end', comment_end_tests)
+    create_tests('test_tag_value_version', tag_value_version_tests)
+    create_tests('test_tag_value_stability', tag_value_stability_tests)
 
     # Run test suite
     main()


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