summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2010-09-23 17:32:58 -0300
committerJohan Dahlin <johan@gnome.org>2010-09-23 17:51:46 -0300
commitbcf7883320d82ba9078f17e901df771b22b968f9 (patch)
tree38a134bdceca2b3f73f970d9afafa57f833451f2 /giscanner
parente2b95cdb39d6e5f287e23dbf30a04031b49a230f (diff)
downloadgobject-introspection-bcf7883320d82ba9078f17e901df771b22b968f9.tar.gz
[annotationparser] Make it a bit stricter
Don't parse annotations on lines such as: '@param: This is a foo (eg, bar) else: x' Where there's content between the last ) and the :.
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/annotationparser.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 937b9be3..04435535 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -278,8 +278,15 @@ class AnnotationParser(object):
first_colonspace_index = line.find(': ')
is_parameter = line.startswith('@')
is_return_value = self.RETURNS_RE.search(line)
+ parse_options = True
if ((is_parameter or is_return_value)
and first_colonspace_index > 0):
+ # Skip lines which has non-whitespace before first (
+ first_paren = line[first_colonspace_index+1:].find('(')
+ if (first_paren != -1 and
+ line[first_colonspace_index+1:first_paren].strip()):
+ parse_options = False
+
if is_parameter:
argname = line[1:first_colonspace_index]
else:
@@ -291,7 +298,11 @@ class AnnotationParser(object):
if second_colon_index > first_colonspace_index:
value_line = \
line[first_colonspace_index+2:second_colon_index]
- if self.OPTION_RE.search(value_line):
+ if ')' in value_line:
+ after_last_paren = value_line[value_line.rfind(')'):]
+ if not after_last_paren.rstrip().endswith(')'):
+ parse_options = False
+ if parse_options and self.OPTION_RE.search(value_line):
# The OPTION_RE is a little bit heuristic. If
# we found two colons, we scan inside for something
# that looks like (foo).