diff --git a/lib/yard/tags/default_factory.rb b/lib/yard/tags/default_factory.rb index 78bfce41e..c4a7ab284 100644 --- a/lib/yard/tags/default_factory.rb +++ b/lib/yard/tags/default_factory.rb @@ -73,6 +73,11 @@ def parse_tag_with_title_and_text(tag_name, text) end def parse_tag_with_types_name_and_default(tag_name, text) + if text.nil? + log.warn "Encountered #{tag_name} tag with no text" + return + end + # Can't allow () in a default tag, otherwise the grammar is too ambiguous when types is omitted. open = TYPELIST_OPENING_CHARS.delete('(') close = TYPELIST_CLOSING_CHARS.delete(')') diff --git a/spec/tags/default_factory_spec.rb b/spec/tags/default_factory_spec.rb index 21b0398d2..5d250e47d 100644 --- a/spec/tags/default_factory_spec.rb +++ b/spec/tags/default_factory_spec.rb @@ -164,5 +164,11 @@ def parse_options(text) expect(t.pair).to be_instance_of(Tags::DefaultTag) expect(t.pair.name).to eq "key" end + + it "returns nil when only name is present" do + expect(log).to receive(:warn).with("Encountered option tag with no text") + t = parse_options("xyz") + expect(t.pair).to be(nil) + end end end