Class: YARD::Handlers::Ruby::MethodHandler

Inherits:
Base
  • Object
show all
Defined in:
lib/yard/handlers/ruby/method_handler.rb

Overview

Handles a method definition

Constant Summary

Constants included from CodeObjects

CodeObjects::BUILTIN_ALL, CodeObjects::BUILTIN_CLASSES, CodeObjects::BUILTIN_EXCEPTIONS, CodeObjects::BUILTIN_EXCEPTIONS_HASH, CodeObjects::BUILTIN_MODULES, CodeObjects::CONSTANTMATCH, CodeObjects::CSEP, CodeObjects::CSEPQ, CodeObjects::ISEP, CodeObjects::ISEPQ, CodeObjects::METHODMATCH, CodeObjects::METHODNAMEMATCH, CodeObjects::NAMESPACEMATCH, CodeObjects::NSEP, CodeObjects::NSEPQ

Instance Attribute Summary

Attributes inherited from Base

#namespace, #owner, #parser, #scope, #statement, #visibility

Instance Method Summary collapse

Methods inherited from Base

handles?, meta_type, method_call, #parse_block

Methods included from Parser::Ruby

#s

Methods inherited from Base

clear_subclasses, #ensure_loaded!, handlers, handles, handles?, in_file, #initialize, matches_file?, namespace_only, namespace_only?, #parse_block, process, #process, #push_state, #register, subclasses

Constructor Details

This class inherits a constructor from YARD::Handlers::Base

Instance Method Details

#format_args(args) ⇒ Object



76
77
78
79
80
81
82
83
84
85
# File 'lib/yard/handlers/ruby/method_handler.rb', line 76

def format_args(args)
  args = args.jump(:params)
  params = []
  params += args.required_params.map {|a| [a.source, nil] } if args.required_params
  params += args.optional_params.map {|a| [a[0].source, a[1].source] } if args.optional_params
  params << ["*" + args.splat_param.source, nil] if args.splat_param
  params += args.required_end_params.map {|a| [a.source, nil] } if args.required_end_params
  params << ["&" + args.block_param.source, nil] if args.block_param
  params
end

#method_signature(method_name) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/yard/handlers/ruby/method_handler.rb', line 87

def method_signature(method_name)
  if statement[1]
    "def #{method_name}(#{statement[1].jump(:params).source})"
  else
    "def #{method_name}"
  end
end