summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2013-08-23 17:01:01 +0200
committerDieter Verfaillie <dieterv@optionexplicit.be>2013-10-08 20:57:20 +0200
commitce352de62e1ccc9ecaa2649d85569acc272ee0ed (patch)
treeffc00c9c149795ed95b2486b1f95a7800de64a8d
parent001631bf9b9e672154492bf6547c0c7c985ed3e0 (diff)
downloadgobject-introspection-ce352de62e1ccc9ecaa2649d85569acc272ee0ed.tar.gz
giscanner: complain about text before the ' * '
Makes our GTK-Doc comment block rewriting tool halt on such issues, requireing user intervention instead of writing back even more bogus data.
-rw-r--r--giscanner/annotationparser.py9
-rw-r--r--tests/scanner/annotationparser/gi/syntax.xml11
-rw-r--r--tests/scanner/annotationparser/test_patterns.py14
3 files changed, 23 insertions, 11 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 7b7d0d1d..244df114 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -324,6 +324,8 @@ COMMENT_ASTERISK_RE = re.compile(
r'''
^ # start
\s* # 0 or more whitespace characters
+ (?P<comment>.*?) # invalid comment text
+ \s* # 0 or more whitespace characters
\* # 1 asterisk character
\s? # 0 or 1 whitespace characters
# WARNING: removing more than 1
@@ -1213,6 +1215,13 @@ class GtkDocCommentBlockParser(object):
# Get rid of the ' * ' at the start of the line.
result = COMMENT_ASTERISK_RE.match(line)
if result:
+ comment = result.group('comment')
+ if comment:
+ marker = ' ' * result.start('comment') + '^'
+ error('invalid comment text:\n%s\n%s' %
+ (original_line, marker),
+ position)
+
column_offset = result.end(0)
line = line[result.end(0):]
diff --git a/tests/scanner/annotationparser/gi/syntax.xml b/tests/scanner/annotationparser/gi/syntax.xml
index b4eff5ac..d1841a35 100644
--- a/tests/scanner/annotationparser/gi/syntax.xml
+++ b/tests/scanner/annotationparser/gi/syntax.xml
@@ -314,7 +314,7 @@ https://bugzilla.gnome.org/show_bug.cgi?id=673806</description>
* content inline. Ordinary HTML links will usually return
* %FALSE, but an inline &lt;src&gt; HTML element will return
* %TRUE.
-a *
+ a *
* Returns: whether or not this link displays its content inline.
*
**/</input>
@@ -332,8 +332,7 @@ a *
<description>Indicates whether the link currently displays some or all of its
content inline. Ordinary HTML links will usually return
%FALSE, but an inline &lt;src&gt; HTML element will return
- %TRUE.
-a *</description>
+ %TRUE.</description>
<tags>
<tag>
<name>returns</name>
@@ -341,6 +340,11 @@ a *</description>
</tag>
</tags>
</docblock>
+ <messages>
+ <message>9: Error: Test: invalid comment text:
+ a *
+ ^</message>
+ </messages>
</parser>
<output>/**
* atk_hyperlink_is_inline:
@@ -350,7 +354,6 @@ a *</description>
* content inline. Ordinary HTML links will usually return
* %FALSE, but an inline &lt;src&gt; HTML element will return
* %TRUE.
- * a *
*
* Returns: whether or not this link displays its content inline.
*/</output>
diff --git a/tests/scanner/annotationparser/test_patterns.py b/tests/scanner/annotationparser/test_patterns.py
index 3362458b..ed687a43 100644
--- a/tests/scanner/annotationparser/test_patterns.py
+++ b/tests/scanner/annotationparser/test_patterns.py
@@ -160,19 +160,19 @@ comment_end_tests = [
comment_asterisk_tests = [
(COMMENT_ASTERISK_RE, '*',
- {}),
+ {'comment': ''}),
(COMMENT_ASTERISK_RE, '* ',
- {}),
+ {'comment': ''}),
(COMMENT_ASTERISK_RE, ' *',
- {}),
+ {'comment': ''}),
(COMMENT_ASTERISK_RE, ' * ',
- {}),
+ {'comment': ''}),
(COMMENT_ASTERISK_RE, ' * ',
- {}),
+ {'comment': ''}),
(COMMENT_ASTERISK_RE, ' * test',
- {}),
+ {'comment': ''}),
(COMMENT_ASTERISK_RE, 'test * ',
- None)]
+ {'comment': 'test'})]
indentaton_tests = [