Class RDoc::Generator::XML

  1. lib/rdoc/generator/xml.rb
ClassModule NormalModule AnonClass SingleClass NormalClass AnyMethod GhostMethod MetaMethod CodeObject Context Alias Attr Constant Require Include TopLevel RubyLex IRB RuntimeError Error Error Token TkUnknownChar TkVal TkNode TkOp TkId TkError TkOPASGN TkKW AttributeFormatter HtmlFormatter OverstrikeFormatter AnsiFormatter NamedThing AliasName IncludedModule Constant Attribute MethodSummary DefaultDisplay ClassEntry TopLevelEntry Formatter SimpleFormatter Description MethodDescription ModuleDescription ClassDescription HTML XML HTMLInOne CHM Method Context Class File Generator::MarkUp TEXINFO SimpleElement Port Element Node Subgraph Edge Digraph Stats Parser Options RDoc TemplatePage Markup Diagram NameDescriptor Cache Reader Writer Driver MethodEntry RI TexinfoTemplate AllReferences RubyToken Display Paths RI MarkUp Generator TokenStream DOT RDoc dot/f_5.png

Generate XML output as one big file

Classes and Modules

Module RDoc::Generator::XML::RDF
Module RDoc::Generator::XML::XML

Public class methods

for (options)

Standard generator factory

[show source]
# File lib/rdoc/generator/xml.rb, line 11
  def self.for(options)
    new(options)
  end
new (*args)
[show source]
# File lib/rdoc/generator/xml.rb, line 15
  def initialize(*args)
    super
  end

Public instance methods

build_class_list (from, html_file, class_dir)
[show source]
# File lib/rdoc/generator/xml.rb, line 53
  def build_class_list(from, html_file, class_dir)
    @classes << RDoc::Generator::Class.new(from, html_file, class_dir, @options)
    from.each_classmodule do |mod|
      build_class_list(mod, html_file, class_dir)
    end
  end
build_indices ()

Generate:

  • a list of File objects for each TopLevel object.
  • a list of Class objects for each first level class or module in the TopLevel objects
  • a complete list of all hyperlinkable terms (file, class, module, and method names)
[show source]
# File lib/rdoc/generator/xml.rb, line 43
  def build_indices
    @info.each do |toplevel|
      @files << RDoc::Generator::File.new(toplevel, @options, RDoc::Generator::FILE_DIR)
    end

    RDoc::TopLevel.all_classes_and_modules.each do |cls|
      build_class_list(cls, @files[0], RDoc::Generator::CLASS_DIR)
    end
  end
gen_an_index (collection, title)
[show source]
# File lib/rdoc/generator/xml.rb, line 101
  def gen_an_index(collection, title)
    res = []
    collection.sort.each do |f|
      if f.document_self
        res << { "href" => f.path, "name" => f.index_name }
      end
    end

    return {
      "entries" => res,
      'list_title' => title,
      'index_url'  => main_url,
    }
  end
gen_class_index ()
[show source]
# File lib/rdoc/generator/xml.rb, line 93
  def gen_class_index
    gen_an_index(@classes, 'Classes')
  end
gen_file_index ()
[show source]
# File lib/rdoc/generator/xml.rb, line 89
  def gen_file_index
    gen_an_index(@files, 'Files')
  end
gen_into (list)
[show source]
# File lib/rdoc/generator/xml.rb, line 81
  def gen_into(list)
    res = []
    list.each do |item|
      res << item.value_hash
    end
    res
  end
gen_method_index ()
[show source]
# File lib/rdoc/generator/xml.rb, line 97
  def gen_method_index
    gen_an_index(RDoc::Generator::HtmlMethod.all_methods, 'Methods')
  end
generate (info)

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

[show source]
# File lib/rdoc/generator/xml.rb, line 24
  def generate(info)
    @info       = info
    @files      = []
    @classes    = []
    @hyperlinks = {}

    build_indices
    generate_xml
  end
generate_xml ()

Generate all the HTML. For the one-file case, we generate all the information in to one big hash

[show source]
# File lib/rdoc/generator/xml.rb, line 64
  def generate_xml
    values = {
      'charset' => @options.charset,
      'files'   => gen_into(@files),
      'classes' => gen_into(@classes)
    }

    template = RDoc::TemplatePage.new @template::ONE_PAGE

    if @options.op_name
      opfile = File.open(@options.op_name, "w")
    else
      opfile = $stdout
    end
    template.write_html_on(opfile, values)
  end