summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2013-07-25 17:22:21 +0200
committerDieter Verfaillie <dieterv@optionexplicit.be>2013-10-08 20:55:43 +0200
commit839e4f10a6b291a261c200484ff05ec44a31d93e (patch)
tree5f4751874fd3f8c98d7dc3ae8d04e4d7e3a20a66
parent1fdb3fc24bec54ccaef132c415d365db4cbd16d9 (diff)
downloadgobject-introspection-839e4f10a6b291a261c200484ff05ec44a31d93e.tar.gz
giscanner: extract tag values
-rw-r--r--gir/gio-2.0.c4
-rw-r--r--gir/glib-2.0.c2
-rw-r--r--giscanner/annotationparser.py63
-rw-r--r--giscanner/maintransformer.py26
-rw-r--r--tests/scanner/annotationparser/gi/annotation_get_value_func.xml2
-rw-r--r--tests/scanner/annotationparser/gi/annotation_ref_func.xml2
-rw-r--r--tests/scanner/annotationparser/gi/annotation_rename_to.xml2
-rw-r--r--tests/scanner/annotationparser/gi/annotation_set_value_func.xml2
-rw-r--r--tests/scanner/annotationparser/gi/annotation_transfer.xml2
-rw-r--r--tests/scanner/annotationparser/gi/annotation_type.xml2
-rw-r--r--tests/scanner/annotationparser/gi/annotation_unref_func.xml2
-rw-r--r--tests/scanner/annotationparser/gi/annotation_value.xml2
-rw-r--r--tests/scanner/annotationparser/gi/annotation_virtual.xml2
-rw-r--r--tests/scanner/annotationparser/gi/parameter_varargs.xml15
-rw-r--r--tests/scanner/annotationparser/gi/syntax_nested_tags.xml2
-rw-r--r--tests/scanner/annotationparser/gi/tag_deprecated.xml9
-rw-r--r--tests/scanner/annotationparser/gi/tag_returns.xml4
-rw-r--r--tests/scanner/annotationparser/gi/tag_since.xml12
-rw-r--r--tests/scanner/annotationparser/gi/tag_stability.xml10
-rw-r--r--tests/scanner/annotationparser/gtkdoc/bugs/tester.c.xml2
-rw-r--r--tests/scanner/annotationparser/gtkdoc/gobject/giface.c.xml2
-rw-r--r--tests/scanner/annotationparser/gtkdoc/gobject/gobject.c.xml8
-rw-r--r--tests/scanner/annotationparser/gtkdoc/gobject/gobject.h.xml2
-rw-r--r--tests/scanner/annotationparser/test_parser.py8
-rw-r--r--tests/scanner/annotationparser/test_patterns.py69
25 files changed, 185 insertions, 71 deletions
diff --git a/gir/gio-2.0.c b/gir/gio-2.0.c
index e41cb3b2..5da24c27 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 aeb682d1..12e79f46 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 1828c743..26e001e1 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 6ffec2fb..af9a0a1b 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 ab71a7db..cfc64281 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 9d159c1e..5f945701 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 dc79d18e..5d9d3b1b 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 5418c9cd..0164a5b8 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 511f24d3..535a4d28 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 16d45319..885b4bcc 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 32bd8921..528923b2 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 e7c7d6f1..c5acb4ed 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 ae8c3be6..e01d9933 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 7eb62361..b873de28 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 b3eaab5e..4ebe0ea4 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 21380143..b33509c4 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 60d3d58c..b5643b37 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 4c586e71..e736aba2 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 c434e563..27976fd8 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 b8aea1ac..1197c9b7 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 65dca481..053b44b4 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 1f619408..7234ed8a 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 66627b55..2fb9696d 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 c88cc266..98ae787e 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 17fc1973..d121ae60 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()