From: Dieter Verfaillie Date: Tue, 17 Jul 2012 15:30:47 +0000 (+0200) Subject: giscanner: treat the GTK-Doc Description: tag like any other tag X-Git-Tag: GOBJECT_INTROSPECTION_1_35_3~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=079b2c5bf9d73ac47a7bb1c62f176cbd85fb1e2a;p=platform%2Fupstream%2Fgobject-introspection.git giscanner: treat the GTK-Doc Description: tag like any other tag and add paragraph break tests. https://bugzilla.gnome.org/show_bug.cgi?id=688897 --- diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index 509579f..179af86 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -48,6 +48,7 @@ TAG_STABILITY = 'stability' TAG_DEPRECATED = 'deprecated' TAG_RETURNS = 'returns' TAG_RETURNVALUE = 'return value' +TAG_DESCRIPTION = 'description' TAG_ATTRIBUTES = 'attributes' TAG_RENAME_TO = 'rename to' TAG_TYPE = 'type' @@ -63,6 +64,7 @@ _ALL_TAGS = [TAG_VFUNC, TAG_DEPRECATED, TAG_RETURNS, TAG_RETURNVALUE, + TAG_DESCRIPTION, TAG_ATTRIBUTES, TAG_RENAME_TO, TAG_TYPE, @@ -296,16 +298,6 @@ PARAMETER_RE = re.compile(r''' ''', re.VERBOSE | re.MULTILINE) -# Program matching old style "Description:" tag. -# -# Results in 0 symbolic groups. -DESCRIPTION_TAG_RE = re.compile(r''' - ^ # start - [^\S\n\r]* # 0 or more whitespace characters - Description: # 'Description:' literal - ''', - re.VERBOSE | re.MULTILINE) - # Program matching tags. # # Results in 4 symbolic groups: @@ -987,6 +979,23 @@ class AnnotationParser(object): tag_annotations = result.group('annotations') tag_description = result.group('description') + marker = ' '*(result.start('tag_name') + column_offset) + '^' + + # Deprecated GTK-Doc Description: tag + if tag_name.lower() == TAG_DESCRIPTION: + message.warn("GTK-Doc tag \"Description:\" has been deprecated:\n%s\n%s" % + (original_line, marker), + position) + + in_part = PART_DESCRIPTION + + if not comment_block.comment: + comment_block.comment = tag_description + else: + comment_block.comment += '\n' + tag_description + continue + + # Now that the deprecated stuff is out of the way, continue parsing real tags if in_part == PART_DESCRIPTION: in_part = PART_TAGS @@ -1041,10 +1050,6 @@ class AnnotationParser(object): #################################################################### if in_part in [PART_IDENTIFIER, PART_DESCRIPTION]: if not comment_block.comment: - # Backwards compatibility with old style GTK-Doc - # comment blocks where Description used to be a comment - # block tag. Simply get rid of 'Description:'. - line = re.sub(DESCRIPTION_TAG_RE, '', line) comment_block.comment = line else: comment_block.comment += '\n' + line diff --git a/tests/scanner/annotationparser/gi/syntax_paragraph_breaks.xml b/tests/scanner/annotationparser/gi/syntax_paragraph_breaks.xml index 6291493..4ae1e03 100644 --- a/tests/scanner/annotationparser/gi/syntax_paragraph_breaks.xml +++ b/tests/scanner/annotationparser/gi/syntax_paragraph_breaks.xml @@ -26,6 +26,28 @@ So this is considered a new paragraph. + /** + * SECTION:test + * + * Description: The following line is ' *' (blank-asterisk). + * + * So this is considered a new paragraph. + */ + + + SECTION:test + + The following line is ' *' (blank-asterisk). + +So this is considered a new paragraph. + + + + + /** @@ -47,6 +69,27 @@ So this is considered a new paragraph. + /** + * SECTION:test + * + * Description: The following line is ' * ' (blank-asterisk-blank). + * + * So this is considered a new paragraph. + */ + + + SECTION:test + + The following line is ' * ' (blank-asterisk-blank). + +So this is considered a new paragraph. + + + + + + /** + * SECTION:test + * + * Description: The following line is (blank-asterisk-blank-blank). + * + * So this is preceded by an empty line and is not considered a new paragraph. + */ + + + SECTION:test + + The following line is (blank-asterisk-blank-blank). + +So this is preceded by an empty line and is not considered a new paragraph. + + + + + + + * Iterating over attributes + * + * void + * print_attributes (GIBaseInfo *info) + * { + * GIAttributeIter iter = { 0, }; + * char *name; + * char *value; + * + * while (g_base_info_iterate_attributes (info, &iter, &name, &value)) + * { + * g_print ("attribute name: %s value: %s", name, value); + * } + * } + * + * + */]]> + + + SECTION:test + + +Iterating over attributes + +void +print_attributes (GIBaseInfo *info) +{ + GIAttributeIter iter = { 0, }; + char *name; + char *value; + + while (g_base_info_iterate_attributes (info, &iter, &name, &value)) + { + g_print ("attribute name: %s value: %s", name, value); + } +} + +]]> + + +