[gobject-introspection] giscanner: fix GTK-Doc section parsing



commit cc43ce2ee57ebec00c339429671e41587ec02a24
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Thu Jul 18 07:19:36 2013 +0200

    giscanner: fix GTK-Doc section parsing

 giscanner/annotationparser.py                   |   10 ++++------
 tests/scanner/annotationparser/test_patterns.py |   18 ++++++------------
 2 files changed, 10 insertions(+), 18 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 8a010e0..b8f243d 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -288,11 +288,7 @@ EMPTY_LINE_RE = re.compile(
     ''',
     re.UNICODE | re.VERBOSE)
 
-# Program matching SECTION identifiers.
-#
-# Results in 2 symbolic groups:
-#   - group 1 = delimiter
-#   - group 2 = section_name
+# Pattern matching SECTION identifiers.
 SECTION_RE = re.compile(
     r'''
     ^                                                    # start
@@ -301,7 +297,9 @@ SECTION_RE = re.compile(
     \s*                                                  # 0 or more whitespace characters
     (?P<delimiter>:?)                                    # delimiter
     \s*                                                  # 0 or more whitespace characters
-    (?P<section_name>\w\S+)?                             # section name
+    (?P<section_name>\w\S+?)                             # section name
+    \s*                                                  # 0 or more whitespace characters
+    :?                                                   # invalid delimiter
     \s*                                                  # 0 or more whitespace characters
     $
     ''',
diff --git a/tests/scanner/annotationparser/test_patterns.py b/tests/scanner/annotationparser/test_patterns.py
index 063b191..17fc197 100644
--- a/tests/scanner/annotationparser/test_patterns.py
+++ b/tests/scanner/annotationparser/test_patterns.py
@@ -47,23 +47,17 @@ identifier_section_tests = [
     (SECTION_RE, 'section:test',
          None),
     (SECTION_RE, 'SECTION',
-         {'delimiter': '',
-          'section_name': None}),
+         None),
     (SECTION_RE, 'SECTION  \t   ',
-         {'delimiter': '',
-          'section_name': None}),
+         None),
     (SECTION_RE, '   \t  SECTION  \t   ',
-         {'delimiter': '',
-          'section_name': None}),
+         None),
     (SECTION_RE, 'SECTION:   \t ',
-         {'delimiter': ':',
-          'section_name': None}),
+         None),
     (SECTION_RE, 'SECTION   :   ',
-         {'delimiter': ':',
-          'section_name': None}),
+         None),
     (SECTION_RE, '   SECTION : ',
-         {'delimiter': ':',
-          'section_name': None}),
+         None),
     (SECTION_RE, 'SECTION:gtkwidget',
          {'delimiter': ':',
           'section_name': 'gtkwidget'}),


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