Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle invalid option tag with name only #1481

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/yard/tags/default_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(')')
Expand Down
6 changes: 6 additions & 0 deletions spec/tags/default_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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