Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update comment parsing rules #134

Merged
merged 2 commits into from
May 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/rake/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ def transform_comments(separator, &block)
private :transform_comments

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

Expand Down
14 changes: 13 additions & 1 deletion test/test_rake_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,24 @@ def test_comment_setting
assert_equal "A Comment", t.comment
end

def test_comments_with_sentences
def test_comments_with_sentences_period
desc "Comment 1. Comment 2."
t = task(:t, :name, :rev)
assert_equal "Comment 1", t.comment
end

def test_comments_with_sentences_exclamation_mark
desc "An exclamation mark! Comment."
t = task(:t, :name, :rev)
assert_equal "An exclamation mark", t.comment
end

def test_comments_with_many_periods
desc "This is a test...I think ... testing. Comment."
t = task(:t, :name, :rev)
assert_equal "This is a test...I think ... testing", t.comment
end

def test_comments_with_tabbed_sentences
desc "Comment 1.\tComment 2."
t = task(:t, :name, :rev)
Expand Down