From b46aecc31746c0a0f38f9cbf6fd2ea882078b072 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Wed, 26 Dec 2018 10:24:52 -0800 Subject: [PATCH] Fix unknown param warning with inline visibility modifier --- lib/yard/handlers/ruby/dsl_handler_methods.rb | 5 +++-- spec/docstring_parser_spec.rb | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/yard/handlers/ruby/dsl_handler_methods.rb b/lib/yard/handlers/ruby/dsl_handler_methods.rb index af3c42097..650d859ac 100644 --- a/lib/yard/handlers/ruby/dsl_handler_methods.rb +++ b/lib/yard/handlers/ruby/dsl_handler_methods.rb @@ -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] diff --git a/spec/docstring_parser_spec.rb b/spec/docstring_parser_spec.rb index 54490cd2f..1d6a9d33c 100644 --- a/spec/docstring_parser_spec.rb +++ b/spec/docstring_parser_spec.rb @@ -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