Class: RDoc::Generator::CHM
- Inherits:
-
Darkfish
- Object
- Darkfish
- RDoc::Generator::CHM
- Defined in:
- lib/rdoc/generator/chm.rb
Constant Summary collapse
- VERSION =
'3.1.0'
- DESCRIPTION =
'Microsoft Compiled HTML Help (chm) generator'
- HHC_PATH =
"#{ENV['PROGRAMFILES']}/HTML Help Workshop/hhc.exe"
Instance Method Summary collapse
-
#assemble_template(body_file) ⇒ Object
This is an override to make sure that the new Darkfish template doesn’t try to parse the CHM files as html partials.
- #check_for_html_help_workshop ⇒ Object
-
#compile_project ⇒ Object
Invoke the windows help compiler to compiler the project.
-
#generate(top_levels) ⇒ Object
Generate the html as normal, then wrap it in a help project.
-
#generate_chm_index ⇒ Object
generate the CHM index (index.hhk).
- #generate_class_index ⇒ Object
-
#generate_contents ⇒ Object
generate the CHM contents (contents.hhc).
- #generate_file_index ⇒ Object
-
#generate_help_project ⇒ Object
The project contains the project file, a table of contents and an index.
-
#generate_project_file ⇒ Object
The project file links together all the various files that go to make up the help.
-
#initialize(options) ⇒ CHM
constructor
A new instance of CHM.
Constructor Details
#initialize(options) ⇒ CHM
Returns a new instance of CHM.
27 28 29 30 |
# File 'lib/rdoc/generator/chm.rb', line 27 def initialize() check_for_html_help_workshop super end |
Instance Method Details
#assemble_template(body_file) ⇒ Object
This is an override to make sure that the new Darkfish template doesn’t try to parse the CHM files as html partials
138 139 140 141 142 143 144 145 |
# File 'lib/rdoc/generator/chm.rb', line 138 def assemble_template body_file if body_file.basename.to_s =~ /\.hh(k|c|p)/ body = body_file.read return body if body else super end end |
#check_for_html_help_workshop ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rdoc/generator/chm.rb', line 32 def check_for_html_help_workshop unless File.exists?(HHC_PATH) warn << "\n.chm output generation requires that Microsoft's Html Help\n" << "Workshop is installed. RDoc looks for it in:\n\n " << HHC_PATH << "\n\nYou can download a copy for free from:\n\n" << " http://msdn.microsoft.com/library/default.asp?" << "url=/library/en-us/htmlhelp/html/hwMicrosoftHTMLHelpDownloads.asp\n\n" end end |
#compile_project ⇒ Object
Invoke the windows help compiler to compiler the project
130 131 132 133 |
# File 'lib/rdoc/generator/chm.rb', line 130 def compile_project debug_msg " compiling #{@project_name}" system(HHC_PATH, @project_name) end |
#generate(top_levels) ⇒ Object
Generate the html as normal, then wrap it in a help project
48 49 50 51 52 |
# File 'lib/rdoc/generator/chm.rb', line 48 def generate top_levels super @project_name = "#{@outputdir.basename}.hhp" generate_help_project end |
#generate_chm_index ⇒ Object
generate the CHM index (index.hhk)
120 121 122 123 124 125 126 |
# File 'lib/rdoc/generator/chm.rb', line 120 def generate_chm_index template_file = @template_dir + 'chm_index.hhk.rhtml' out_file = @outputdir + "index.hhk" debug_msg " rendering #{out_file}" render_template template_file, out_file do |io| binding end end |
#generate_class_index ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rdoc/generator/chm.rb', line 81 def generate_class_index template_file = @template_dir + 'classindex.rhtml' out_file = @outputdir + "classindex.html" debug_msg " rendering #{out_file}" # suppress 1.9.3 warning rel_prefix = rel_prefix = @outputdir.relative_path_from(out_file.dirname) render_template template_file, out_file do |io| binding end end |
#generate_contents ⇒ Object
generate the CHM contents (contents.hhc)
110 111 112 113 114 115 116 |
# File 'lib/rdoc/generator/chm.rb', line 110 def generate_contents template_file = @template_dir + 'contents.hhc.rhtml' out_file = @outputdir + "contents.hhc" debug_msg " rendering #{out_file}" render_template template_file, out_file do |io| binding end end |
#generate_file_index ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rdoc/generator/chm.rb', line 70 def generate_file_index template_file = @template_dir + 'fileindex.rhtml' out_file = @outputdir + "fileindex.html" # suppress 1.9.3 warning rel_prefix = rel_prefix = @outputdir.relative_path_from(out_file.dirname) debug_msg " rendering #{out_file}" render_template template_file, out_file do |io| binding end end |
#generate_help_project ⇒ Object
The project contains the project file, a table of contents and an index
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rdoc/generator/chm.rb', line 57 def generate_help_project # Set which files should actually be generated @generated_files = @files.select { |f| f.text? } debug_msg "Generating the help project files" generate_file_index generate_class_index generate_project_file generate_contents generate_chm_index compile_project end |
#generate_project_file ⇒ Object
The project file links together all the various files that go to make up the help.
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/rdoc/generator/chm.rb', line 95 def generate_project_file template_file = @template_dir + 'hhp_file.hhp.rhtml' @values = { :title => @options.title, :opname => @outputdir.basename } static_files = ['index.html', 'classindex.html', 'fileindex.html'] @values[:html_files] = static_files + (@generated_files+@classes).map{|f| f.path}.uniq out_file = @outputdir + @project_name debug_msg " rendering #{out_file}" render_template template_file, out_file do |io| binding end end |