Permalink
Browse files

Fix support for option hashes.

  • Loading branch information...
1 parent 63ebccf commit 5dc87fe407cbf35504e856c1fc0142eb6c377000 @jonasoberschweiber jonasoberschweiber committed Oct 11, 2012
Showing with 19 additions and 4 deletions.
  1. +3 −3 lib/yard-tomdoc.rb
  2. +16 −1 test/unit/test_docstring.rb
View
6 lib/yard-tomdoc.rb
@@ -37,9 +37,9 @@ def self.yard_parse(yard, comment)
# TODO: how to figure-out class of argument ?
tomdoc.arguments.each {|arg| yard.create_tag(:param, "#{arg.name} #{arg.description}") }
- if last_argument = tomdoc.arguments.last
- last_argument.options.each do |opt|
- yard.create_tag(:option, "#{last_argument.name} #{opt.description}")
+ tomdoc.arguments.each do |arg|
+ arg.options.each do |opt|
+ yard.create_tag(:option, "#{arg.name} #{opt.name} #{opt.description}")
end
end
View
17 test/unit/test_docstring.rb
@@ -19,6 +19,9 @@
#
# text - The String to be duplicated.
# count - The Integer number of times to duplicate the text.
+# options - Options (default: {})
+# :a - Option a
+# :b - Option b
#
# Examples
# multiplex('Tom', 4)
@@ -38,9 +41,21 @@
it "should fill param tags" do
tags = @docstring.tags(:param)
- tags.size.assert == 2
+ tags.size.assert == 3
tags[0].name.assert == 'text'
tags[1].name.assert == 'count'
+ tags[2].name.assert == 'options'
+ end
+
+ it "should fill options tags" do
+ tags = @docstring.tags(:option)
+ tags.size.assert == 2
+ tags[0].name.assert == 'options'
+ tags[0].pair.name.assert == ':a'
+ tags[0].pair.text.assert == 'Option a'
+ tags[1].name.assert == 'options'
+ tags[1].pair.name.assert == ':b'
+ tags[1].pair.text.assert == 'Option b'
end
it "should fill examples tags" do

0 comments on commit 5dc87fe

Please sign in to comment.