diff --git a/spec/templates/tag_spec.rb b/spec/templates/tag_spec.rb index 5fcf3ed93..5e5b641ab 100644 --- a/spec/templates/tag_spec.rb +++ b/spec/templates/tag_spec.rb @@ -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 diff --git a/templates/default/tags/html/option.erb b/templates/default/tags/html/option.erb index 0a6babccf..64e3ac7ce 100644 --- a/templates/default/tags/html/option.erb +++ b/templates/default/tags/html/option.erb @@ -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? %>