diff --git a/lib/yard/tags/overload_tag.rb b/lib/yard/tags/overload_tag.rb index 2d7ec6ae1..739495ab1 100644 --- a/lib/yard/tags/overload_tag.rb +++ b/lib/yard/tags/overload_tag.rb @@ -60,7 +60,8 @@ def parse_signature args = YARD::Handlers::Ruby::Legacy::Base.new(nil, nil).send(:tokval_list, toks, :all) args = args.map do |a| k, v = *a.split(/:|=/, 2) - [k.strip.to_s + (a[k.size, 1] == ':' ? ':' : ''), (v ? v.strip : nil)] + v.strip! if v + [k.strip.to_s + (a[k.size, 1] == ':' ? ':' : ''), (v && v.empty? ? nil : v)] end if args @name = meth.to_sym @parameters = args diff --git a/spec/tags/overload_tag_spec.rb b/spec/tags/overload_tag_spec.rb index 8246c8f73..1bc296853 100644 --- a/spec/tags/overload_tag_spec.rb +++ b/spec/tags/overload_tag_spec.rb @@ -50,4 +50,19 @@ def bar(a, b = 1, &block) tag = Tags::OverloadTag.new(:overload, "default") expect(tag.signature).to eq "default" end + + it "properly handles complex signatures" do + tag = Tags::OverloadTag.new(:overload, "foo(a, b = 1, *c, d, e:, f: 2, g:, **rest, &block)") + expect(tag.parameters).to eq [ + ['a', nil], + ['b', "1"], + ['*c', nil], + ['d', nil], + ['e:', nil], + ['f:', "2"], + ['g:', nil], + ['**rest', nil], + ['&block', nil], + ] + end end