diff options
author | Johan Dahlin <johan@gnome.org> | 2010-09-23 17:32:58 -0300 |
---|---|---|
committer | Johan Dahlin <johan@gnome.org> | 2010-09-23 17:51:46 -0300 |
commit | bcf7883320d82ba9078f17e901df771b22b968f9 (patch) | |
tree | 38a134bdceca2b3f73f970d9afafa57f833451f2 | |
parent | e2b95cdb39d6e5f287e23dbf30a04031b49a230f (diff) | |
download | gobject-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 :.
-rw-r--r-- | giscanner/annotationparser.py | 13 | ||||
-rw-r--r-- | tests/warn/invalid-option.h | 9 |
2 files changed, 20 insertions, 2 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). diff --git a/tests/warn/invalid-option.h b/tests/warn/invalid-option.h index 22483bb9..88cd2512 100644 --- a/tests/warn/invalid-option.h +++ b/tests/warn/invalid-option.h @@ -1,8 +1,15 @@ /** * func: - * @param: (invalid-annotation-option): + * @param: (invalid-annotation-option): sizeof (x) == 1 */ void test_func(int param); // EXPECT:4: Warning: Test: invalid option: invalid-annotation-option + +/** + * func_weird_gtk_doc: + * @param: Foo (e.g. bar) baz: + * @param2: This is a (bar): + */ +void test_func_weird_gtk_doc(int param, int param2); |