In Files

  • rdoc/generators/ri_generator.rb

Files

Class/Module Index [+]

Quicksearch

Generators::RIGenerator

Public Class Methods

for(options) click to toggle source

Generators may need to return specific subclasses depending on the options they are passed. Because of this we create them using a factory

 
               # File rdoc/generators/ri_generator.rb, line 59
def RIGenerator.for(options)
  new(options)
end
            

Public Instance Methods

generate(toplevels) click to toggle source

Build the initial indices and output objects based on an array of TopLevel objects containing the extracted information.

 
               # File rdoc/generators/ri_generator.rb, line 83
def generate(toplevels)
  RDoc::TopLevel.all_classes_and_modules.each do |cls|
    process_class(cls)
  end
end
            
generate_class_info(cls) click to toggle source
 
               # File rdoc/generators/ri_generator.rb, line 98
def generate_class_info(cls)
  if cls === RDoc::NormalModule
    cls_desc = RI::ModuleDescription.new
  else
    cls_desc = RI::ClassDescription.new
    cls_desc.superclass  = cls.superclass
  end
  cls_desc.name        = cls.name
  cls_desc.full_name   = cls.full_name
  cls_desc.comment     = markup(cls.comment)

  cls_desc.attributes =cls.attributes.sort.map do |a|
    RI::Attribute.new(a.name, a.rw, markup(a.comment))
  end

  cls_desc.constants = cls.constants.map do |c|
    RI::Constant.new(c.name, c.value, markup(c.comment))
  end

  cls_desc.includes = cls.includes.map do |i|
    RI::IncludedModule.new(i.name)
  end

  class_methods, instance_methods = method_list(cls)

  cls_desc.class_methods = class_methods.map do |m|
    RI::MethodSummary.new(m.name)
  end
  cls_desc.instance_methods = instance_methods.map do |m|
    RI::MethodSummary.new(m.name)
  end

  update_or_replace(cls_desc)

  class_methods.each do |m|
    generate_method_info(cls_desc, m)
  end

  instance_methods.each do |m|
    generate_method_info(cls_desc, m)
  end
end
            
generate_method_info(cls_desc, method) click to toggle source
 
               # File rdoc/generators/ri_generator.rb, line 142
def generate_method_info(cls_desc, method)
  meth_desc = RI::MethodDescription.new
  meth_desc.name = method.name
  meth_desc.full_name = cls_desc.full_name
  if method.singleton
    meth_desc.full_name += "::"
  else
    meth_desc.full_name += "#"
  end
  meth_desc.full_name << method.name

  meth_desc.comment = markup(method.comment)
  meth_desc.params = params_of(method)
  meth_desc.visibility = method.visibility.to_s
  meth_desc.is_singleton = method.singleton
  meth_desc.block_params = method.block_params

  meth_desc.aliases = method.aliases.map do |a|
    RI::AliasName.new(a.name)
  end

  @ri_writer.add_method(cls_desc, meth_desc)
end
            
process_class(from_class) click to toggle source
 
               # File rdoc/generators/ri_generator.rb, line 89
def process_class(from_class)
  generate_class_info(from_class)

  # now recure into this classes constituent classess
  from_class.each_classmodule do |mod|
    process_class(mod)
  end
end
            

Protected Instance Methods

initialize(options) click to toggle source

Set up a new HTML generator. Basically all we do here is load up the correct output temlate

 
               # File rdoc/generators/ri_generator.rb, line 70
def initialize(options) #:not-new:
  @options   = options
  @ri_writer = RI::RiWriter.new(".")
  @markup    = SM::SimpleMarkup.new
  @to_flow   = SM::ToFlow.new
end