Skip to content

Commit 3a64f88

Browse files
committed
Fix error when @option with non-method
1 parent abcba4b commit 3a64f88

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

spec/templates/tag_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,16 @@ module Foo; end
4949
.not_to raise_error
5050
end
5151
end
52+
53+
describe "option tags on non-methods" do
54+
it "does not display @option tags on non-method objects" do
55+
YARD.parse_string <<-'eof'
56+
# @option opts name [#to_s] ('bar') the name
57+
module Foo; end
58+
eof
59+
60+
expect { Registry.at('Foo').format(html_options) }
61+
.not_to raise_error
62+
end
63+
end
5264
end

templates/default/tags/html/option.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<% if object.has_tag?(:option) %>
1+
<% if object.has_tag?(:option) && object.respond_to?(:parameters) %>
22
<% object.parameters.each do |param, default| %>
33
<% tags = object.tags(:option).select {|x| x.name.to_s == param.to_s.sub(/^\*+|:$/, '') } %>
44
<% next if tags.empty? %>

0 commit comments

Comments
 (0)