Skip to content

Commit

Permalink
Fix Docstring#to_raw for @option tags
Browse files Browse the repository at this point in the history
Implementation by @ConradIrwin
  • Loading branch information
lsegal committed Jul 14, 2012
1 parent 4d2ddcd commit 72de4e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/yard/docstring.rb
Expand Up @@ -191,6 +191,13 @@ def to_raw
unless tag.docstring.blank?
tag_text += "\n" + tag.docstring.all.gsub(/\r?\n/, "\n ")
end
when Tags::OptionTag
tag_text = "@#{tag.tag_name} #{tag.name}"
tag_text += ' [' + tag.pair.types.join(', ') + ']' if tag.pair.types
tag_text += ' ' + tag.pair.name.to_s if tag.pair.name
tag_text += "\n " if tag.name && tag.text
tag_text += ' (' + tag.pair.defaults.join(', ') + ')' if tag.pair.defaults
tag_text += " " + tag.pair.text.strip.gsub(/\n/, "\n ") if tag.pair.text
else
tag_text = '@' + tag.tag_name
tag_text += ' [' + tag.types.join(', ') + ']' if tag.types
Expand Down
12 changes: 12 additions & 0 deletions spec/docstring_spec.rb
Expand Up @@ -250,6 +250,18 @@
doc = Docstring.new("123\n@param")
doc.to_raw.should == doc.all
end

# @bug gh-563
it "should handle full @option tags" do
doc = Docstring.new("@option foo [String] bar (nil) baz")
doc.to_raw.should == "@option foo [String] bar (nil) baz"
end

# @bug gh-563
it "should handle simple @option tags" do
doc = Docstring.new("@option foo :key bar")
doc.to_raw.should == "@option foo :key bar"
end
end

describe '#dup' do
Expand Down

0 comments on commit 72de4e6

Please sign in to comment.