Method: YARD::Handlers::Ruby::MethodHandler#process

Defined in:
lib/yard/handlers/ruby/method_handler.rb

#processvoid

This method returns an undefined value.

Main processing callback



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/yard/handlers/ruby/method_handler.rb', line 8

process do
  meth = statement.method_name(true).to_s
  args = format_args
  blk = statement.block
  nobj = namespace
  mscope = scope
  if statement.type == :defs
    if statement[0][0].type == :ident
      raise YARD::Parser::UndocumentableError, 'method defined on object instance'
    end
    nobj = P(namespace, statement[0].source) if statement[0][0].type == :const
    mscope = :class
  end

  nobj = P(namespace, nobj.value) while nobj.type == :constant
  obj = register MethodObject.new(nobj, meth, mscope) do |o|
    o.explicit = true
    o.parameters = args
  end

  # delete any aliases referencing old method
  nobj.aliases.each do |aobj, name|
    next unless name == obj.name
    nobj.aliases.delete(aobj)
  end if nobj.is_a?(NamespaceObject)

  if obj.constructor?
    unless obj.has_tag?(:return)
      obj.add_tag(YARD::Tags::Tag.new(:return,
        "a new instance of #{namespace.name}", namespace.name.to_s))
    end
  elsif mscope == :class && obj.docstring.blank? && %w(inherited included
      extended method_added method_removed method_undefined).include?(meth)
    obj.add_tag(YARD::Tags::Tag.new(:private, nil))
  elsif meth.to_s =~ /\?$/
    add_predicate_return_tag(obj)
  end

  if obj.has_tag?(:option)
    # create the options parameter if its missing
    obj.tags(:option).each do |option|
      expected_param = option.name
      unless obj.tags(:param).find {|x| x.name == expected_param }
        new_tag = YARD::Tags::Tag.new(:param, "a customizable set of options", "Hash", expected_param)
        obj.add_tag(new_tag)
      end
    end
  end

  info = obj.attr_info
  if info
    if meth.to_s =~ /=$/ # writer
      info[:write] = obj if info[:read]
    elsif info[:write]
      info[:read] = obj
    end
  end

  parse_block(blk, :owner => obj) # mainly for yield/exceptions
end