Skip to content

Commit

Permalink
Strip newlines in summary to fix formatting issues
Browse files Browse the repository at this point in the history
Fixes #686
  • Loading branch information
lsegal committed Jul 26, 2013
1 parent fa272a6 commit 45808e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/yard/docstring.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def line
def summary
resolve_reference
return @summary if @summary
stripped = self.gsub(/<.+?>/m, '').strip
stripped = self.gsub(/<.+?>/m, '').gsub(/[\r\n](?![\r\n])/, ' ').strip
open_parens = ['{', '(', '[']
close_parens = ['}', ')', ']']
num_parens = 0
Expand Down
5 changes: 5 additions & 0 deletions spec/docstring_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
doc.summary.should == 'Hello world.'
end

it "should strip newlines in first paragraph before summarizing" do
doc = Docstring.new("Foo\n<code>==</code> bar.")
doc.summary.should == 'Foo == bar.'
end

it "should return the first sentence" do
o = Docstring.new("DOCSTRING. Another sentence")
o.summary.should == "DOCSTRING."
Expand Down

0 comments on commit 45808e9

Please sign in to comment.