[gobject-introspection] Accept trailing whitespace at the start of a comment block
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Accept trailing whitespace at the start of a comment block
- Date: Tue, 19 Oct 2010 12:46:39 +0000 (UTC)
commit 2e8e7530fc66b3222525a236a395b8d24eecf404
Author: Colin Walters <walters verbum org>
Date: Tue Oct 19 08:45:13 2010 -0400
Accept trailing whitespace at the start of a comment block
Might as well be liberal here, as long as we have a test case.
https://bugzilla.gnome.org/show_bug.cgi?id=631690
giscanner/annotationparser.py | 8 +++-----
tests/scanner/Annotation-1.0-expected.gir | 7 +++++++
tests/scanner/annotation.c | 11 +++++++++++
tests/scanner/annotation.h | 3 +++
4 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 5e45e5d..03a8883 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -25,9 +25,6 @@ import re
from . import message
from .odict import odict
-# All gtk-doc comments needs to start with this:
-_COMMENT_HEADER = '*\n '
-
# Tags - annotations applyed to comment blocks
TAG_VFUNC = 'virtual'
TAG_SINCE = 'since'
@@ -405,6 +402,7 @@ class DocOption(object):
class AnnotationParser(object):
+ COMMENT_HEADER_RE = re.compile(r'^\*[ \t]*\n ')
WHITESPACE_RE = re.compile(r'^\s*$')
ASCII_TEXT_RE = re.compile(r'\s*[A-Za-z]+')
OPTION_RE = re.compile(r'\([A-Za-z]+[^(]*\)')
@@ -434,9 +432,9 @@ class AnnotationParser(object):
#
comment, filename, lineno = cmt
comment = comment.lstrip()
- if not comment.startswith(_COMMENT_HEADER):
+ if not self.COMMENT_HEADER_RE.search(comment):
return
- comment = comment[len(_COMMENT_HEADER):]
+ comment = self.COMMENT_HEADER_RE.sub('', comment, count=1)
comment = comment.strip()
if not comment.startswith('* '):
return
diff --git a/tests/scanner/Annotation-1.0-expected.gir b/tests/scanner/Annotation-1.0-expected.gir
index 050d888..6dcb23c 100644
--- a/tests/scanner/Annotation-1.0-expected.gir
+++ b/tests/scanner/Annotation-1.0-expected.gir
@@ -737,6 +737,13 @@ detection, and fixing it via annotations.</doc>
</parameter>
</parameters>
</function>
+ <function name="space_after_comment_bug631690"
+ c:identifier="annotation_space_after_comment_bug631690">
+ <doc xml:whitespace="preserve">Explicitly test having a space after the ** here.</doc>
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ </function>
<function name="string_array_length"
c:identifier="annotation_string_array_length">
<return-value transfer-ownership="none">
diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c
index 280a9e5..4c25178 100644
--- a/tests/scanner/annotation.c
+++ b/tests/scanner/annotation.c
@@ -771,3 +771,14 @@ annotation_test_parsing_bug630862 (void)
{
return NULL;
}
+
+
+/**
+ * annotation_space_after_comment_bug631690:
+ *
+ * Explicitly test having a space after the ** here.
+ */
+void
+annotation_space_after_comment_bug631690 (void)
+{
+}
diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h
index ef05ddb..e315af5 100644
--- a/tests/scanner/annotation.h
+++ b/tests/scanner/annotation.h
@@ -158,5 +158,8 @@ void annotation_ptr_array (GPtrArray *array);
GObject * annotation_test_parsing_bug630862 (void);
+void annotation_space_after_comment_bug631690 (void);
+
+
#endif /* __ANNOTATION_OBJECT_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]