Skip to content

Commit

Permalink
Merge pull request #9 from jonasoberschweiber/master
Browse files Browse the repository at this point in the history
Support option hashes for all arguments.
  • Loading branch information
trans committed Oct 11, 2012
2 parents 63ebccf + 5dc87fe commit 59f7ece
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/yard-tomdoc.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def self.yard_parse(yard, comment)
# TODO: how to figure-out class of argument ? # TODO: how to figure-out class of argument ?
tomdoc.arguments.each {|arg| yard.create_tag(:param, "#{arg.name} #{arg.description}") } tomdoc.arguments.each {|arg| yard.create_tag(:param, "#{arg.name} #{arg.description}") }


if last_argument = tomdoc.arguments.last tomdoc.arguments.each do |arg|
last_argument.options.each do |opt| arg.options.each do |opt|
yard.create_tag(:option, "#{last_argument.name} #{opt.description}") yard.create_tag(:option, "#{arg.name} #{opt.name} #{opt.description}")
end end
end end


Expand Down
17 changes: 16 additions & 1 deletion test/unit/test_docstring.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
# #
# text - The String to be duplicated. # text - The String to be duplicated.
# count - The Integer number of times to duplicate the text. # count - The Integer number of times to duplicate the text.
# options - Options (default: {})
# :a - Option a
# :b - Option b
# #
# Examples # Examples
# multiplex('Tom', 4) # multiplex('Tom', 4)
Expand All @@ -38,9 +41,21 @@


it "should fill param tags" do it "should fill param tags" do
tags = @docstring.tags(:param) tags = @docstring.tags(:param)
tags.size.assert == 2 tags.size.assert == 3
tags[0].name.assert == 'text' tags[0].name.assert == 'text'
tags[1].name.assert == 'count' 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 end


it "should fill examples tags" do it "should fill examples tags" do
Expand Down

0 comments on commit 59f7ece

Please sign in to comment.