summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2012-04-17 22:23:14 +0200
committerDieter Verfaillie <dieterv@optionexplicit.be>2012-04-17 23:03:22 +0200
commitc87ef59b4b4e57f7704144c2098b5ab0bf37976e (patch)
tree37b5651810377b9b1d75ad6a8d01ac03f1e81608 /giscanner
parentf4729860f3b397a868a6e9135ce51975b1d043f1 (diff)
downloadgobject-introspection-c87ef59b4b4e57f7704144c2098b5ab0bf37976e.tar.gz
annotationparser: cleanup and add tests for the new warnings we now emit
Including: - handle things in the logical order encountered (first colon, then annotations) - correctly report column when missing a colon on the identifier part - small type fixes - remove no longer useful "parameter/tag expected" warnings
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/annotationparser.py51
-rw-r--r--giscanner/annotationpatterns.py2
2 files changed, 22 insertions, 31 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 82fc9eef..2ac1b0eb 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -27,7 +27,7 @@ import re
from . import message
from .annotationpatterns import (COMMENT_START_RE, COMMENT_END_RE,
- COMMENT_STAR_RE, EMPTY_LINE_RE,
+ COMMENT_ASTERISK_RE, EMPTY_LINE_RE,
SECTION_RE, SYMBOL_RE, PROPERTY_RE, SIGNAL_RE,
PARAMETER_RE, DESCRIPTION_TAG_RE, TAG_RE,
MULTILINE_ANNOTATION_CONTINUATION_RE)
@@ -616,7 +616,7 @@ class AnnotationParser(object):
column_offset = 0
# Get rid of ' * ' at start of the line.
- result = COMMENT_STAR_RE.match(line)
+ result = COMMENT_ASTERISK_RE.match(line)
if result:
column_offset = result.end(0)
line = line[result.end(0):]
@@ -672,17 +672,18 @@ class AnnotationParser(object):
comment_block = DocBlock(identifier_name)
comment_block.set_position(position)
- if 'annotations' in result.groupdict():
- comment_block.options = self.parse_options(comment_block,
- result.group('annotations'))
-
if 'colon' in result.groupdict() and result.group('colon') != ':':
colon_start = result.start('colon')
colon_column = column_offset + colon_start
marker = ' '*colon_column + '^'
message.warn("missing ':' at column %s:\n%s\n%s" %
- (colon_start, original_line, marker),
+ (colon_column + 1, original_line, marker),
position)
+
+ if 'annotations' in result.groupdict():
+ comment_block.options = self.parse_options(comment_block,
+ result.group('annotations'))
+
continue
else:
# If we get here, the identifier was not recognized, so
@@ -812,7 +813,7 @@ class AnnotationParser(object):
if tag_name.lower() == TAG_ATTRIBUTES:
tag.options = self.parse_options(tag, tag_annotations)
else:
- message.warn("annotations not supported for tag '%s'." %
+ message.warn("annotations not supported for tag '%s:'." %
(tag_name),
position)
comment_block.tags[tag_name.lower()] = tag
@@ -823,7 +824,7 @@ class AnnotationParser(object):
# If we get here, we must be in the middle of a multiline
# comment block, parameter or tag description.
####################################################################
- if in_part == PART_DESCRIPTION:
+ if in_part == PART_DESCRIPTION or in_part == PART_IDENTIFIER:
if not comment_block.comment:
# Backwards compatibility with old style GTK-Doc
# comment blocks where Description used to be a comment
@@ -834,30 +835,20 @@ class AnnotationParser(object):
comment_block.comment += '\n' + line
continue
elif in_part == PART_PARAMETERS:
- if not current_param:
- message.warn('parameter expected:\n%s' %
- (line),
- position)
- else:
- self._validate_multiline_annotation_continuation(line, original_line,
- column_offset, position)
+ self._validate_multiline_annotation_continuation(line, original_line,
+ column_offset, position)
- # Append to parameter description.
- current_param.comment += ' ' + line.strip()
+ # Append to parameter description.
+ current_param.comment += ' ' + line.strip()
elif in_part == PART_TAGS:
- if not current_tag:
- message.warn('tag expected:\n%s' %
- (line),
- position)
- else:
- self._validate_multiline_annotation_continuation(line, original_line,
- column_offset, position)
+ self._validate_multiline_annotation_continuation(line, original_line,
+ column_offset, position)
- # Append to tag description.
- if current_tag.name.lower() in [TAG_RETURNS, TAG_RETURNVALUE]:
- current_tag.comment += ' ' + line.strip()
- else:
- current_tag.value += ' ' + line.strip()
+ # Append to tag description.
+ if current_tag.name.lower() in [TAG_RETURNS, TAG_RETURNVALUE]:
+ current_tag.comment += ' ' + line.strip()
+ else:
+ current_tag.value += ' ' + line.strip()
########################################################################
# Finished parsing this comment block.
diff --git a/giscanner/annotationpatterns.py b/giscanner/annotationpatterns.py
index 80b9da41..a4030051 100644
--- a/giscanner/annotationpatterns.py
+++ b/giscanner/annotationpatterns.py
@@ -61,7 +61,7 @@ COMMENT_END_RE = re.compile(r'''
# line inside a comment block.
#
# Results in 0 symbolic groups.
-COMMENT_STAR_RE = re.compile(r'''
+COMMENT_ASTERISK_RE = re.compile(r'''
^ # start
[^\S\n\r]* # 0 or more whitespace characters
\* # 1 asterisk character