''',
re.VERBOSE)
-# Program matching the end of a comment block.
+# Program matching the end of a comment block. We need to take care
+# of comment ends that aren't on their own line for legacy support
+# reasons. See https://bugzilla.gnome.org/show_bug.cgi?id=689354
#
-# Results in 0 symbolic groups.
+# Results in 1 symbolic group:
+# - group 1 = description
COMMENT_END_RE = re.compile(r'''
^ # start
[^\S\n\r]* # 0 or more whitespace characters
+ (?P<description>.*?) # description text
+ [^\S\n\r]* # 0 or more whitespace characters
\*+ # 1 or more asterisk characters
/ # 1 forward slash character
+ [^\S\n\r]* # 0 or more whitespace characters
$ # end
''',
re.VERBOSE)
return None
# Check for the end the comment block.
- if COMMENT_END_RE.match(comment_lines[-1][1]):
- del comment_lines[-1]
+ line_offset, line = comment_lines[-1]
+ result = COMMENT_END_RE.match(line)
+ if result:
+ description = result.group('description')
+ if description:
+ comment_lines[-1] = (line_offset, description)
+ position = message.Position(filename, lineno + line_offset)
+ marker = ' '*result.end('description') + '^'
+ message.warn("Comments should end with */ on a new line:\n%s\n%s" %
+ (line, marker),
+ position)
+ else:
+ del comment_lines[-1]
else:
# Not a GTK-Doc comment block.
return None
<test>
<!--
- Not GTK-Doc
+ Technically not GTK-Doc, but we need to support this for backwards compatibility
-->
<commentblock>/**
Test
something */</commentblock>
+ <docblock>
+ <identifier>
+ <name>Test</name>
+ </identifier>
+ <description>something</description>
+ </docblock>
</test>
<test>
<!--
- Not GTK-Doc
+ Technically not GTK-Doc, but we need to support this for backwards compatibility
-->
<commentblock>/**
Test
something **/</commentblock>
+ <docblock>
+ <identifier>
+ <name>Test</name>
+ </identifier>
+ <description>something</description>
+ </docblock>
</test>
-
<test>
<!--
Broken comment block, signal the start of the comment block description followed
from giscanner.annotationparser import (SECTION_RE, SYMBOL_RE, PROPERTY_RE,
- SIGNAL_RE, PARAMETER_RE, TAG_RE)
+ SIGNAL_RE, PARAMETER_RE, TAG_RE,
+ COMMENT_END_RE)
from unittest import (TestCase, main)
'colon': ':',
'description': ''})]
+comment_end_tests = [
+ (COMMENT_END_RE, '*/',
+ {'description': ''}),
+ (COMMENT_END_RE, ' */',
+ {'description': ''}),
+ (COMMENT_END_RE, ' */ ',
+ {'description': ''}),
+ (COMMENT_END_RE, '**/',
+ {'description': ''}),
+ (COMMENT_END_RE, ' **/',
+ {'description': ''}),
+ (COMMENT_END_RE, ' **/ ',
+ {'description': ''}),
+ (COMMENT_END_RE, 'test */',
+ {'description': 'test'}),
+ (COMMENT_END_RE, ' test*/',
+ {'description': 'test'}),
+ (COMMENT_END_RE, 'test **/',
+ {'description': 'test'}),
+ (COMMENT_END_RE, ' test**/',
+ {'description': 'test'}),
+ (COMMENT_END_RE, 'test *****/',
+ {'description': 'test'}),
+ (COMMENT_END_RE, ' test*****/',
+ {'description': 'test'})]
+
def create_tests(tests_name, testcases):
for (index, testcase) in enumerate(testcases):
create_tests('test_identifier_signal', identifier_signal_tests)
create_tests('test_parameter', parameter_tests)
create_tests('test_tag', tag_tests)
+ create_tests('test_comment_end', comment_end_tests)
# Run test suite
main()