2008-01-12 22:13:37 -05:00
|
|
|
require 'rdoc/generator/html'
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
##
|
|
|
|
# Generate XML output as one big file
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-12 22:13:37 -05:00
|
|
|
class RDoc::Generator::XML < RDoc::Generator::HTML
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
##
|
|
|
|
# Standard generator factory
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
def self.for(options)
|
|
|
|
new(options)
|
|
|
|
end
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
def initialize(*args)
|
|
|
|
super
|
|
|
|
end
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
##
|
|
|
|
# Build the initial indices and output objects
|
|
|
|
# based on an array of TopLevel objects containing
|
|
|
|
# the extracted information.
|
|
|
|
|
|
|
|
def generate(info)
|
|
|
|
@info = info
|
|
|
|
@files = []
|
|
|
|
@classes = []
|
|
|
|
@hyperlinks = {}
|
|
|
|
|
|
|
|
build_indices
|
|
|
|
generate_xml
|
|
|
|
end
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
##
|
|
|
|
# Generate:
|
|
|
|
#
|
2008-09-24 22:43:03 -04:00
|
|
|
# * a list of File objects for each TopLevel object.
|
|
|
|
# * a list of Class objects for each first level
|
2008-01-06 20:36:33 -05:00
|
|
|
# class or module in the TopLevel objects
|
|
|
|
# * a complete list of all hyperlinkable terms (file,
|
|
|
|
# class, module, and method names)
|
|
|
|
|
|
|
|
def build_indices
|
|
|
|
@info.each do |toplevel|
|
2008-09-24 22:43:03 -04:00
|
|
|
@files << RDoc::Generator::File.new(toplevel, @options, RDoc::Generator::FILE_DIR)
|
2003-12-01 02:12:49 -05:00
|
|
|
end
|
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
RDoc::TopLevel.all_classes_and_modules.each do |cls|
|
2008-01-12 22:13:37 -05:00
|
|
|
build_class_list(cls, @files[0], RDoc::Generator::CLASS_DIR)
|
2003-12-01 02:12:49 -05:00
|
|
|
end
|
2008-01-06 20:36:33 -05:00
|
|
|
end
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
def build_class_list(from, html_file, class_dir)
|
2008-09-24 22:43:03 -04:00
|
|
|
@classes << RDoc::Generator::Class.new(from, html_file, class_dir, @options)
|
2008-01-06 20:36:33 -05:00
|
|
|
from.each_classmodule do |mod|
|
|
|
|
build_class_list(mod, html_file, class_dir)
|
2003-12-01 02:12:49 -05:00
|
|
|
end
|
2008-01-06 20:36:33 -05:00
|
|
|
end
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
##
|
|
|
|
# Generate all the HTML. For the one-file case, we generate
|
|
|
|
# all the information in to one big hash
|
2008-01-06 19:42:03 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
def generate_xml
|
|
|
|
values = {
|
|
|
|
'charset' => @options.charset,
|
|
|
|
'files' => gen_into(@files),
|
|
|
|
'classes' => gen_into(@classes)
|
|
|
|
}
|
2008-01-06 19:42:03 -05:00
|
|
|
|
2008-01-12 22:02:49 -05:00
|
|
|
template = RDoc::TemplatePage.new @template::ONE_PAGE
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
if @options.op_name
|
|
|
|
opfile = File.open(@options.op_name, "w")
|
|
|
|
else
|
|
|
|
opfile = $stdout
|
2003-12-01 02:12:49 -05:00
|
|
|
end
|
2008-01-06 20:36:33 -05:00
|
|
|
template.write_html_on(opfile, values)
|
|
|
|
end
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
def gen_into(list)
|
|
|
|
res = []
|
|
|
|
list.each do |item|
|
|
|
|
res << item.value_hash
|
2003-12-01 02:12:49 -05:00
|
|
|
end
|
2008-01-06 20:36:33 -05:00
|
|
|
res
|
|
|
|
end
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
def gen_file_index
|
|
|
|
gen_an_index(@files, 'Files')
|
|
|
|
end
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
def gen_class_index
|
|
|
|
gen_an_index(@classes, 'Classes')
|
|
|
|
end
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
def gen_method_index
|
2008-01-12 22:13:37 -05:00
|
|
|
gen_an_index(RDoc::Generator::HtmlMethod.all_methods, 'Methods')
|
2008-01-06 20:36:33 -05:00
|
|
|
end
|
2003-12-01 02:12:49 -05:00
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
def gen_an_index(collection, title)
|
|
|
|
res = []
|
|
|
|
collection.sort.each do |f|
|
|
|
|
if f.document_self
|
|
|
|
res << { "href" => f.path, "name" => f.index_name }
|
2003-12-01 02:12:49 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-01-06 20:36:33 -05:00
|
|
|
return {
|
|
|
|
"entries" => res,
|
|
|
|
'list_title' => title,
|
|
|
|
'index_url' => main_url,
|
|
|
|
}
|
2003-12-01 02:12:49 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2008-01-06 19:42:03 -05:00
|
|
|
|