class RDoc::AnyMethod

def <=>(other)

def <=>(other)
  [@singleton ? 0 : 1, @name] <=> [other.singleton ? 0 : 1, other.name]
end

def add_alias(method)

def add_alias(method)
  @aliases << method
end

def add_line_numbers(src)

def add_line_numbers(src)
  if src =~ /\A.*, line (\d+)/ then
    first = $1.to_i - 1
    last  = first + src.count("\n")
    size = last.to_s.length
    line = first
    src.gsub!(/^/) do
      res = if line == first then
              " " * (size + 2)
            else
              "%2$*1$d: " % [size, line]
            end
      line += 1
      res
    end
  end
end

def aref

def aref
  type = singleton ? 'c' : 'i'
  "method-#{type}-#{CGI.escape name}"
end

def arglists

def arglists
  if @call_seq then
    @call_seq
  elsif @params then
    "#{name}#{param_seq}"
  end
end

def full_name

def full_name
  @full_name ||= "#{@parent ? @parent.full_name : '(unknown)'}#{pretty_name}"
end

def html_name

def html_name
  @name.gsub(/[^a-z]+/, '-')
end

def initialize(text, name)

def initialize(text, name)
  super()
  @text = text
  @name = name
  @aliases                = []
  @block_params           = nil
  @call_seq               = nil
  @dont_rename_initialize = false
  @is_alias_for           = nil
  @params                 = nil
  @parent_name            = nil
  @singleton              = nil
  @token_stream           = nil
  @visibility             = :public
end

def inspect # :nodoc:

:nodoc:
def inspect # :nodoc:
  alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil
  "#<%s:0x%x %s (%s)%s>" % [
    self.class, object_id,
    full_name,
    visibility,
    alias_for,
  ]
end

def markup_code

def markup_code
  return '' unless @token_stream
  src = ""
  @token_stream.each do |t|
    next unless t
    #        style = STYLE_MAP[t.class]
    style = case t
            when RDoc::RubyToken::TkCONSTANT then "ruby-constant"
            when RDoc::RubyToken::TkKW       then "ruby-keyword kw"
            when RDoc::RubyToken::TkIVAR     then "ruby-ivar"
            when RDoc::RubyToken::TkOp       then "ruby-operator"
            when RDoc::RubyToken::TkId       then "ruby-identifier"
            when RDoc::RubyToken::TkNode     then "ruby-node"
            when RDoc::RubyToken::TkCOMMENT  then "ruby-comment cmt"
            when RDoc::RubyToken::TkREGEXP   then "ruby-regexp re"
            when RDoc::RubyToken::TkSTRING   then "ruby-value str"
            when RDoc::RubyToken::TkVal      then "ruby-value"
            else
              nil
            end
    text = CGI.escapeHTML t.text
    if style
      src << "<span class=\"#{style}\">#{text}</span>"
    else
      src << text
    end
  end
  add_line_numbers src
  src
end

def marshal_dump

def marshal_dump
  aliases = @aliases.map do |a|
    [a.full_name, parse(a.comment)]
  end
  [ MARSHAL_VERSION,
    @name,
    full_name,
    @singleton,
    @visibility,
    parse(@comment),
    @call_seq,
    @block_params,
    aliases,
    @params,
  ]
end

def marshal_load(array)

def marshal_load(array)
  @dont_rename_initialize = nil
  @is_alias_for           = nil
  @token_stream           = nil
  @aliases                = []
  @name         = array[1]
  @full_name    = array[2]
  @singleton    = array[3]
  @visibility   = array[4]
  @comment      = array[5]
  @call_seq     = array[6]
  @block_params = array[7]
  @params       = array[9]
  @parent_name = if @full_name =~ /#/ then
                   $`
                 else
                   name = @full_name.split('::')
                   name.pop
                   name.join '::'
                 end
  array[8].each do |new_name, comment|
    add_alias RDoc::Alias.new(nil, @name, new_name, comment)
  end
end

def name

def name
  return @name if @name
  @name = @call_seq[/^.*?\.(\w+)/, 1] || @call_seq if @call_seq
end

def param_seq

def param_seq
  params = @params.gsub(/\s*\#.*/, '')
  params = params.tr("\n", " ").squeeze(" ")
  params = "(#{params})" unless params[0] == ?(
  if @block_params then
    # If this method has explicit block parameters, remove any explicit
    # &block
    params.sub!(/,?\s*&\w+/, '')
    block = @block_params.gsub(/\s*\#.*/, '')
    block = block.tr("\n", " ").squeeze(" ")
    if block[0] == ?(
      block.sub!(/^\(/, '').sub!(/\)/, '')
    end
    params << " { |#{block}| ... }"
  end
  params
end

def parent_name

def parent_name
  @parent_name || super
end

def path

def path
  "#{@parent.path}##{aref}"
end

def pretty_name

def pretty_name
  "#{singleton ? '::' : '#'}#{@name}"
end

def pretty_print q # :nodoc:

:nodoc:
def pretty_print q # :nodoc:
  alias_for = @is_alias_for ? "alias for #{@is_alias_for.name}" : nil
  q.group 2, "[#{self.class.name} #{full_name} #{visibility}", "]" do
    if alias_for then
      q.breakable
      q.text alias_for
    end
    if text then
      q.breakable
      q.text "text:"
      q.breakable
      q.pp @text
    end
    unless comment.empty? then
      q.breakable
      q.text "comment:"
      q.breakable
      q.pp @comment
    end
  end
end

def to_s # :nodoc:

:nodoc:
def to_s # :nodoc:
  "#{self.class.name}: #{full_name} (#{@text})\n#{@comment}"
end

def type

def type
  singleton ? 'class' : 'instance'
end