| Class | RDoc::Generator::CHM |
| In: |
generator/chm.rb
|
| Parent: | RDoc::Generator::HTML |
Standard generator factory
# File generator/chm.rb, line 10
10: def self.for(options)
11: new(options)
12: end
# File generator/chm.rb, line 14
14: def initialize(*args)
15: super
16: @op_name = @options.op_name || "rdoc"
17: check_for_html_help_workshop
18: end
# File generator/chm.rb, line 20
20: def check_for_html_help_workshop
21: stat = File.stat(HHC_PATH)
22: rescue
23: $stderr <<
24: "\n.chm output generation requires that Microsoft's Html Help\n" <<
25: "Workshop is installed. RDoc looks for it in:\n\n " <<
26: HHC_PATH <<
27: "\n\nYou can download a copy for free from:\n\n" <<
28: " http://msdn.microsoft.com/library/default.asp?" <<
29: "url=/library/en-us/htmlhelp/html/hwMicrosoftHTMLHelpDownloads.asp\n\n"
30: end
Invoke the windows help compiler to compiler the project
# File generator/chm.rb, line 108
108: def compile_project
109: system(HHC_PATH, @project_name)
110: end
The contents is a list of all files and modules. For each we include as sub-entries the list of methods they contain. As we build the contents we also build an index file
# File generator/chm.rb, line 75
75: def create_contents_and_index
76: contents = []
77: index = []
78:
79: (@files+@classes).sort.each do |entry|
80: content_entry = { "c_name" => entry.name, "ref" => entry.path }
81: index << { "name" => entry.name, "aref" => entry.path }
82:
83: internals = []
84:
85: methods = entry.build_method_summary_list(entry.path)
86:
87: content_entry["methods"] = methods unless methods.empty?
88: contents << content_entry
89: index.concat methods
90: end
91:
92: values = { "contents" => contents }
93: template = RDoc::TemplatePage.new @template::CONTENTS
94: File.open("contents.hhc", "w") do |f|
95: template.write_html_on(f, values)
96: end
97:
98: values = { "index" => index }
99: template = RDoc::TemplatePage.new @template::CHM_INDEX
100: File.open("index.hhk", "w") do |f|
101: template.write_html_on(f, values)
102: end
103: end
The project contains the project file, a table of contents and an index
# File generator/chm.rb, line 44
44: def create_help_project
45: create_project_file
46: create_contents_and_index
47: compile_project
48: end
The project file links together all the various files that go to make up the help.
# File generator/chm.rb, line 54
54: def create_project_file
55: template = RDoc::TemplatePage.new @template::HPP_FILE
56: values = { "title" => @options.title, "opname" => @op_name }
57: files = []
58: @files.each do |f|
59: files << { "html_file_name" => f.path }
60: end
61:
62: values['all_html_files'] = files
63:
64: File.open(@project_name, "w") do |f|
65: template.write_html_on(f, values)
66: end
67: end