class YARD::Tags::MethodDirective

@since 0.7.0
@see tag:!attribute
create_methods :method1, :method2
# @!method method2
# @!method method1
@example Attaching multiple methods to the same source
quit_message_method
# @param [String] message the quit message
# @param [String] username the username to quit
# Sends a quit message to the server for a username.
# @!method quit(username, message = “Quit”)
@example Defining a simple method
docstring text.
no indented block, the entire docstring is used as the new method’s
the method’s docstring text. If a +@!method+ directive is seen with
@note For backwards compatibility support, you do not need to indent
documentation to the method definition itself.
is declared dynamically via meta-programming). In all other cases, add
declaration for the method in any source files (i.e., the method
@note This directive should only be used if there is no explicit
To define an attribute method, see {tag:!attribute}
used as the method’s source.
to be attached to any source, but if it is, that source code will be
{tag:overload} tag. The comment containing this directive does not need
block data as the method’s docstring. The signature is similar to the
Defines a method object with a given method signature, using indented

def after_parse

def after_parse
  return unless handler
  use_indented_text
  create_object
end

def call; end

def call; end

def create_object

def create_object
  name = method_name
  scope = parser.state.scope || handler.scope
  visibility = parser.state.visibility || handler.visibility
  ns = CodeObjects::NamespaceObject === object ? object : handler.namespace
  obj = CodeObjects::MethodObject.new(ns, name, scope)
  handler.register_file_info(obj)
  handler.register_source(obj)
  handler.register_visibility(obj, visibility)
  handler.register_group(obj)
  obj.signature = method_signature
  obj.parameters = OverloadTag.new(:overload, method_signature).parameters
  obj.docstring = Docstring.new!(parser.text, parser.tags, obj,
    parser.raw_text, parser.reference)
  handler.register_module_function(obj)
  old_obj = parser.object
  parser.object = obj
  parser.post_process
  parser.object = old_obj
  obj
end

def method_name

def method_name
  sig = sanitized_tag_signature
  if sig && sig =~ /^#{CodeObjects::METHODNAMEMATCH}(\s|\(|$)/
    sig[/\A\s*([^\(; \t]+)/, 1]
  else
    handler.call_params.first
  end
end

def method_signature

def method_signature
  "def #{sanitized_tag_signature || method_name}"
end

def sanitized_tag_signature

def sanitized_tag_signature
  if tag.name && tag.name =~ SCOPE_MATCH
    parser.state.scope = :class
    $'
  else
    tag.name
  end
end

def use_indented_text

def use_indented_text
  return if tag.text.empty?
  handler = parser.handler
  object = parser.object
  self.parser = parser.class.new(parser.library)
  parser.state.inside_directive = true
  parser.parse(tag.text, object, handler)
  parser.state.inside_directive = false
end