Skip to content

Commit

Permalink
Merge pull request #1211 from dduugg/fix-pcm-warn
Browse files Browse the repository at this point in the history
Fix unknown param warning with inline method modifier
  • Loading branch information
lsegal authored Jan 22, 2019
2 parents ce80848 + b46aecc commit 47b7e82
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/yard/handlers/ruby/dsl_handler_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ module DSLHandlerMethods
include Parser

IGNORE_METHODS = Hash[*%w(alias alias_method autoload attr attr_accessor
attr_reader attr_writer extend include public private protected
private_constant).map {|n| [n, true] }.flatten]
attr_reader attr_writer extend include module_function public private
protected private_constant private_class_method public_class_method).
map {|n| [n, true] }.flatten]

def handle_comments
return if IGNORE_METHODS[caller_method]
Expand Down
18 changes: 18 additions & 0 deletions spec/docstring_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,24 @@ def foo(a) end
alias bar foo
eof
end

it "does not warn on matching param with inline method modifier" do
expect(log).to_not receive(:warn)
YARD.parse_string <<-eof
# @param [Numeric] a
# @return [Numeric]
private_class_method def self.foo(a); a + 1; end
eof
end

it "warns on mismatching param with inline method modifier" do
expect(log).to receive(:warn).with(/@param tag has unknown parameter name: notaparam/)
YARD.parse_string <<-eof
# @param [Numeric] notaparam
# @return [Numeric]
private_class_method def self.foo(a); a + 1; end
eof
end
end

describe "after_parse (see)" do
Expand Down

0 comments on commit 47b7e82

Please sign in to comment.