[gobject-introspection] giscanner: complain about text before the ' * '



commit ce352de62e1ccc9ecaa2649d85569acc272ee0ed
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Fri Aug 23 17:01:01 2013 +0200

    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.

 giscanner/annotationparser.py                   |    9 +++++++++
 tests/scanner/annotationparser/gi/syntax.xml    |   11 +++++++----
 tests/scanner/annotationparser/test_patterns.py |   14 +++++++-------
 3 files changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 7b7d0d1..244df11 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 b4eff5a..d1841a3 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 3362458..ed687a4 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 = [


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]