Skip to content

Commit 3c14200

Browse files
authored
Merge pull request #1590 from pvande/patch-1
Update signature handling in @overload
2 parents e96ae99 + 7641cc5 commit 3c14200

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Diff for: lib/yard/tags/overload_tag.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def parse_signature
6060
args = YARD::Handlers::Ruby::Legacy::Base.new(nil, nil).send(:tokval_list, toks, :all)
6161
args = args.map do |a|
6262
k, v = *a.split(/:|=/, 2)
63-
[k.strip.to_s + (a[k.size, 1] == ':' ? ':' : ''), (v ? v.strip : nil)]
63+
v.strip! if v
64+
[k.strip.to_s + (a[k.size, 1] == ':' ? ':' : ''), (v && v.empty? ? nil : v)]
6465
end if args
6566
@name = meth.to_sym
6667
@parameters = args

Diff for: spec/tags/overload_tag_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,19 @@ def bar(a, b = 1, &block)
5050
tag = Tags::OverloadTag.new(:overload, "default")
5151
expect(tag.signature).to eq "default"
5252
end
53+
54+
it "properly handles complex signatures" do
55+
tag = Tags::OverloadTag.new(:overload, "foo(a, b = 1, *c, d, e:, f: 2, g:, **rest, &block)")
56+
expect(tag.parameters).to eq [
57+
['a', nil],
58+
['b', "1"],
59+
['*c', nil],
60+
['d', nil],
61+
['e:', nil],
62+
['f:', "2"],
63+
['g:', nil],
64+
['**rest', nil],
65+
['&block', nil],
66+
]
67+
end
5368
end

0 commit comments

Comments
 (0)