# File 'lib/yard/handlers/ruby/legacy/method_handler.rb', line 5processdonobj=namespacemscope=scopeifstatement.tokens.to_s=~/^def\s+(#{METHODMATCH})(?:(?:\s+|\s*\()(.*)(?:\)\s*$)?)?/mmeth,args=$1,$2meth.gsub!(/\s+/,'')args=tokval_list(YARD::Parser::Ruby::Legacy::TokenList.new(args),:all)args.map!{|a|k,v=*a.split('=',2);[k.strip,(v?v.strip:nil)]}ifargselseraiseYARD::Parser::UndocumentableError,"method: invalid name"end# Class method if prefixed by self(::|.) or Module(::|.)
ifmeth=~/(?:#{NSEPQ}|#{CSEPQ})([^#{NSEP}#{CSEPQ}]+)$/mscope,meth,prefix=:class,$1,$`ifprefix=~/^[a-z]/&&prefix!="self"raiseYARD::Parser::UndocumentableError,'method defined on object instance'endnobj=P(namespace,prefix)unlessprefix=="self"endnobj=P(namespace,nobj.value)whilenobj.type==:constantobj=registerMethodObject.new(nobj,meth,mscope)do|o|o.visibility=visibilityo.source=statemento.explicit=trueo.parameters=argsend# delete any aliases referencing old method
nobj.aliases.eachdo|aobj,name|nextunlessname==obj.namenobj.aliases.delete(aobj)endifnobj.is_a?(NamespaceObject)ifmscope==:instance&&meth=="initialize"unlessobj.has_tag?(:return)obj.docstring.add_tag(YARD::Tags::Tag.new(:return,"a new instance of #{namespace.name}",namespace.name.to_s))endelsifmscope==:class&&obj.docstring.blank?&&%w(inheritedincluded extendedmethod_addedmethod_removedmethod_undefined).include?(meth)obj.docstring.add_tag(YARD::Tags::Tag.new(:private,nil))elsifmeth.to_s=~/\?$/ifobj.tag(:return)&&(obj.tag(:return).types||[]).empty?obj.tag(:return).types=['Boolean']elsifobj.tag(:return).nil?obj.docstring.add_tag(YARD::Tags::Tag.new(:return,"","Boolean"))endendifobj.has_tag?(:option)# create the options parameter if its missing
obj.tags(:option).eachdo|option|expected_param=option.nameunlessobj.tags(:param).find{|x|x.name==expected_param}new_tag=YARD::Tags::Tag.new(:param,"a customizable set of options","Hash",expected_param)obj.docstring.add_tag(new_tag)endendendifinfo=obj.attr_infoifmeth.to_s=~/=$/# writer
info[:write]=objifinfo[:read]elseinfo[:read]=objifinfo[:write]endendparse_block(:owner=>obj)# mainly for yield/exceptions
end