Skip to content

Commit f67c571

Browse files
committed
Merge pull request #134 from leethomas/update-comment-parsing-rules
Update comment parsing rules
2 parents a238c04 + 355d1ac commit f67c571

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/rake/task.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,10 @@ def transform_comments(separator, &block)
304304
private :transform_comments
305305

306306
# Get the first sentence in a string. The sentence is terminated
307-
# by the first period or the end of the line. Decimal points do
308-
# not count as periods.
307+
# by the first period, exclamation mark, or the end of the line.
308+
# Decimal points do not count as periods.
309309
def first_sentence(string)
310-
string.split(/\.[ \t]|\.$|\n/).first
310+
string.split(/(?<=\w)(\.|!)[ \t]|(\.$|!)|\n/).first
311311
end
312312
private :first_sentence
313313

test/test_rake_task.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,24 @@ def test_comment_setting
352352
assert_equal "A Comment", t.comment
353353
end
354354

355-
def test_comments_with_sentences
355+
def test_comments_with_sentences_period
356356
desc "Comment 1. Comment 2."
357357
t = task(:t, :name, :rev)
358358
assert_equal "Comment 1", t.comment
359359
end
360360

361+
def test_comments_with_sentences_exclamation_mark
362+
desc "An exclamation mark! Comment."
363+
t = task(:t, :name, :rev)
364+
assert_equal "An exclamation mark", t.comment
365+
end
366+
367+
def test_comments_with_many_periods
368+
desc "This is a test...I think ... testing. Comment."
369+
t = task(:t, :name, :rev)
370+
assert_equal "This is a test...I think ... testing", t.comment
371+
end
372+
361373
def test_comments_with_tabbed_sentences
362374
desc "Comment 1.\tComment 2."
363375
t = task(:t, :name, :rev)

0 commit comments

Comments
 (0)