Sha256: 92571f23f940b332b505c8aab1cc7dd0792142cad554ae4f0848d2d8ac606772

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

class YARD::Handlers::Ruby::Legacy::MethodHandler < YARD::Handlers::Ruby::Legacy::Base
  handles TkDEF
    
  def process
    nobj = namespace
    mscope = scope

    if statement.tokens.to_s =~ /^def\s+(#{METHODMATCH})(?:(?:\s+|\s*\()(.*)(?:\)\s*$)?)?/m
      meth, args = $1, $2
      meth.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)] } if args
    else
      raise YARD::Parser::UndocumentableError, "method: invalid name"
    end
    
    # Class method if prefixed by self(::|.) or Module(::|.)
    if meth =~ /(?:#{NSEPQ}|#{CSEPQ})([^#{NSEP}#{CSEPQ}]+)$/
      mscope, meth = :class, $1
      nobj = P(namespace, $`) unless $` == "self"
    end
    
    obj = register MethodObject.new(nobj, meth, mscope) do |o| 
      o.visibility = visibility 
      o.source = statement
      o.explicit = true
      o.parameters = args
    end
    parse_block(:owner => obj) # mainly for yield/exceptions
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yard-0.2.3.5 lib/yard/handlers/ruby/legacy/method_handler.rb
yard-0.2.3.4 lib/yard/handlers/ruby/legacy/method_handler.rb
yard-0.2.3.2 lib/yard/handlers/ruby/legacy/method_handler.rb
yard-0.2.3.3 lib/yard/handlers/ruby/legacy/method_handler.rb
yard-0.2.3 lib/yard/handlers/ruby/legacy/method_handler.rb