| Class | RDoc::Generator::XML |
| In: |
generator/xml.rb
|
| Parent: | RDoc::Generator::HTML |
Generate XML output as one big file
Standard generator factory
# File generator/xml.rb, line 11
11: def self.for(options)
12: new(options)
13: end
# File generator/xml.rb, line 53
53: def build_class_list(from, html_file, class_dir)
54: @classes << RDoc::Generator::HtmlClass.new(from, html_file, class_dir, @options)
55: from.each_classmodule do |mod|
56: build_class_list(mod, html_file, class_dir)
57: end
58: end
Generate:
# File generator/xml.rb, line 43
43: def build_indices
44: @info.each do |toplevel|
45: @files << RDoc::Generator::HtmlFile.new(toplevel, @options, RDoc::Generator::FILE_DIR)
46: end
47:
48: RDoc::TopLevel.all_classes_and_modules.each do |cls|
49: build_class_list(cls, @files[0], RDoc::Generator::CLASS_DIR)
50: end
51: end
# File generator/xml.rb, line 104
104: def gen_an_index(collection, title)
105: res = []
106: collection.sort.each do |f|
107: if f.document_self
108: res << { "href" => f.path, "name" => f.index_name }
109: end
110: end
111:
112: return {
113: "entries" => res,
114: 'list_title' => title,
115: 'index_url' => main_url,
116: }
117: end
# File generator/xml.rb, line 96
96: def gen_class_index
97: gen_an_index(@classes, 'Classes')
98: end
# File generator/xml.rb, line 84
84: def gen_into(list)
85: res = []
86: list.each do |item|
87: res << item.value_hash
88: end
89: res
90: end
# File generator/xml.rb, line 100
100: def gen_method_index
101: gen_an_index(RDoc::Generator::HtmlMethod.all_methods, 'Methods')
102: end
Build the initial indices and output objects based on an array of TopLevel objects containing the extracted information.
# File generator/xml.rb, line 24
24: def generate(info)
25: @info = info
26: @files = []
27: @classes = []
28: @hyperlinks = {}
29:
30: build_indices
31: generate_xml
32: end
Generate all the HTML. For the one-file case, we generate all the information in to one big hash
# File generator/xml.rb, line 64
64: def generate_xml
65: values = {
66: 'charset' => @options.charset,
67: 'files' => gen_into(@files),
68: 'classes' => gen_into(@classes)
69: }
70:
71: # this method is defined in the template file
72: write_extra_pages if defined? write_extra_pages
73:
74: template = RDoc::TemplatePage.new @template::ONE_PAGE
75:
76: if @options.op_name
77: opfile = File.open(@options.op_name, "w")
78: else
79: opfile = $stdout
80: end
81: template.write_html_on(opfile, values)
82: end