Skip to content

Commit

Permalink
Merge pull request #1508 from ksss/non-method-option
Browse files Browse the repository at this point in the history
Fix error when `@option` with non-method
  • Loading branch information
lsegal authored Sep 30, 2023
2 parents abcba4b + 3a64f88 commit 2d197a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions spec/templates/tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,16 @@ module Foo; end
.not_to raise_error
end
end

describe "option tags on non-methods" do
it "does not display @option tags on non-method objects" do
YARD.parse_string <<-'eof'
# @option opts name [#to_s] ('bar') the name
module Foo; end
eof

expect { Registry.at('Foo').format(html_options) }
.not_to raise_error
end
end
end
2 changes: 1 addition & 1 deletion templates/default/tags/html/option.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if object.has_tag?(:option) %>
<% if object.has_tag?(:option) && object.respond_to?(:parameters) %>
<% object.parameters.each do |param, default| %>
<% tags = object.tags(:option).select {|x| x.name.to_s == param.to_s.sub(/^\*+|:$/, '') } %>
<% next if tags.empty? %>
Expand Down

0 comments on commit 2d197a3

Please sign in to comment.