module YARD::Templates::Helpers::HtmlHelper

def signature(meth, link = true, show_extras = true, full_attr_name = true)

Returns:
  • (String) - the formatted method signature

Parameters:
  • full_attr_name (Boolean) -- whether to show the full attribute name
  • show_extras (Boolean) -- whether to show extra meta-data (visibility, attribute info)
  • link (Boolean) -- whether to link the method signature to the details view
  • meth (CodeObjects::MethodObject) -- the method object to list
def signature(meth, link = true, show_extras = true, full_attr_name = true)
  meth = convert_method_to_overload(meth)
  type = signature_types(meth, link)
  type = "⇒ #{type}" if type && !type.empty?
  scope = meth.scope == :class ? "." : "#"
  name = full_attr_name ? meth.name : meth.name.to_s.gsub(/^(\w+)=$/, '\1')
  blk = format_block(meth)
  args = !full_attr_name && meth.writer? ? "" : format_args(meth)
  extras = []
  extras_text = ''
  if show_extras
    rw = meth.attr_info
    if rw
      attname = [rw[:read] ? 'read' : nil, rw[:write] ? 'write' : nil].compact
      attname = attname.size == 1 ? attname.join('') + 'only' : nil
      extras << attname if attname
    end
    extras << meth.visibility if meth.visibility != :public
    extras_text = ' <span class="extras">(' + extras.join(", ") + ')</span>' unless extras.empty?
  end
  title = "%s<strong>%s</strong>%s %s %s" % [scope, h(name), args, blk, type]
  if link
    if meth.is_a?(YARD::CodeObjects::MethodObject)
      link_title = "#{h meth.name(true)} (#{meth.scope} #{meth.type})"
    else
      link_title = "#{h name} (#{meth.type})"
    end
    obj = meth.respond_to?(:object) ? meth.object : meth
    url = url_for(object, obj)
    link_url(url, title, :title => link_title) + extras_text
  else
    title + extras_text
  end
end