diff --git a/lib/rdoc/code_object/alias.rb b/lib/rdoc/code_object/alias.rb index 3a86777e4f..9bfea3d107 100644 --- a/lib/rdoc/code_object/alias.rb +++ b/lib/rdoc/code_object/alias.rb @@ -29,13 +29,23 @@ class RDoc::Alias < RDoc::CodeObject # Creates a new Alias that aliases +old_name+ # to +new_name+, has +comment+ and is a +singleton+ context. - def initialize(old_name, new_name, comment, singleton: false) + def initialize(*args, singleton: false) super() + if args.size == 4 + warn(<<~MSG, uplevel: 1, category: :deprecated) + Support for passing 4 arguments to RDoc::Alias.new is deprecated and will be removed. \ + Simply drop the first argument. + MSG + args.shift + elsif args.size != 3 + raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 3)" + end + @singleton = singleton - @old_name = old_name - @new_name = new_name - self.comment = comment + @old_name = args[0] + @new_name = args[1] + self.comment = args[2] end ## diff --git a/lib/rdoc/code_object/any_method.rb b/lib/rdoc/code_object/any_method.rb index cda994d369..0315700814 100644 --- a/lib/rdoc/code_object/any_method.rb +++ b/lib/rdoc/code_object/any_method.rb @@ -41,8 +41,18 @@ class RDoc::AnyMethod < RDoc::MethodAttr ## # Creates a new AnyMethod with name +name+ - def initialize(name, singleton: false) - super(name, singleton: singleton) + def initialize(*args, singleton: false) + if args.size == 2 + warn(<<~MSG, uplevel: 1, category: :deprecated) + Support for passing 2 arguments to RDoc::AnyMethod.new is deprecated and will be removed. \ + Simply drop the first argument. + MSG + args.shift + elsif args.size != 1 + raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 1)" + end + + super(name = args[0], singleton: singleton) @c_function = nil @dont_rename_initialize = false diff --git a/lib/rdoc/code_object/attr.rb b/lib/rdoc/code_object/attr.rb index fb7156b11e..3fa1b22924 100644 --- a/lib/rdoc/code_object/attr.rb +++ b/lib/rdoc/code_object/attr.rb @@ -24,11 +24,21 @@ class RDoc::Attr < RDoc::MethodAttr # Creates a new Attr with +name+, read/write status +rw+ and # +comment+. +singleton+ marks this as a class attribute. - def initialize(name, rw, comment, singleton: false) - super(name, singleton: singleton) + def initialize(*args, singleton: false) + if args.size == 4 + warn(<<~MSG, uplevel: 1, category: :deprecated) + Support for passing 4 arguments to RDoc::Attr.new is deprecated and will be removed. \ + Simply drop the first argument. + MSG + args.shift + elsif args.size != 3 + raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 3)" + end + + super(args[0], singleton: singleton) - @rw = rw - self.comment = comment + @rw = args[1] + self.comment = args[2] end ##