Permalink
Browse files

Fix Docstring#to_raw for `@option` tags

Implementation by @ConradIrwin
  • Loading branch information...
lsegal committed Jul 14, 2012
1 parent 4d2ddcd commit 72de4e624b466b69b4f4f0a90e64b252cbe82174
Showing with 19 additions and 0 deletions.
  1. +7 −0 lib/yard/docstring.rb
  2. +12 −0 spec/docstring_spec.rb
View
@@ -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
View
@@ -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

0 comments on commit 72de4e6

Please sign in to comment.