Class: RDoc::Generator::CHM

Inherits:
Darkfish
  • Object
show all
Defined in:
lib/rdoc/generator/chm.rb

Constant Summary collapse

VERSION =
'2.4.0'
HHC_PATH =
"c:/Program Files/HTML Help Workshop/hhc.exe"

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CHM

Returns a new instance of CHM.



25
26
27
28
# File 'lib/rdoc/generator/chm.rb', line 25

def initialize(options)
  super
  check_for_html_help_workshop
end

Instance Method Details

#check_for_html_help_workshopObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rdoc/generator/chm.rb', line 30

def check_for_html_help_workshop
  stat = File.stat(HHC_PATH)
rescue
  $stderr <<
    "\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

#compile_projectObject

Invoke the windows help compiler to compiler the project



118
119
120
121
# File 'lib/rdoc/generator/chm.rb', line 118

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



45
46
47
48
49
# File 'lib/rdoc/generator/chm.rb', line 45

def generate( top_levels )
  super
  @project_name = "#{@outputdir.basename}.hhp"
  generate_help_project
end

#generate_chm_indexObject

generate the CHM index (index.hhk)



108
109
110
111
112
113
114
# File 'lib/rdoc/generator/chm.rb', line 108

def generate_chm_index
  templatefile = @template_dir + 'chm_index.rhtml'
  
  outfile = @outputdir + "index.hhk"
  debug_msg "  rendering #{outfile}"
  self.render_template( templatefile, binding(), outfile )
end

#generate_class_indexObject



72
73
74
75
76
77
78
# File 'lib/rdoc/generator/chm.rb', line 72

def generate_class_index
  templatefile = @template_dir + 'classindex.rhtml'

  outfile = @outputdir + "classindex.html"
  debug_msg "  rendering #{outfile}"
  self.render_template( templatefile, binding(), outfile )
end

#generate_contentsObject

generate the CHM contents (contents.hhc)



98
99
100
101
102
103
104
# File 'lib/rdoc/generator/chm.rb', line 98

def generate_contents
  templatefile = @template_dir + 'contents.rhtml'

  outfile = @outputdir + "contents.hhc"
  debug_msg "  rendering #{outfile}"
  self.render_template( templatefile, binding(), outfile )
end

#generate_file_indexObject



64
65
66
67
68
69
70
# File 'lib/rdoc/generator/chm.rb', line 64

def generate_file_index
  templatefile = @template_dir + 'fileindex.rhtml'

  outfile = @outputdir + "fileindex.html"
  debug_msg "  rendering #{outfile}"
  self.render_template( templatefile, binding(), outfile )
end

#generate_help_projectObject

The project contains the project file, a table of contents and an index



54
55
56
57
58
59
60
61
62
# File 'lib/rdoc/generator/chm.rb', line 54

def generate_help_project
  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_fileObject

The project file links together all the various files that go to make up the help.



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/rdoc/generator/chm.rb', line 83

def generate_project_file
  templatefile = @template_dir + 'hpp_file.rhtml'

  @values = { :title => @options.title, :opname => @outputdir.basename }
  
  static_files = ['index.html', 'classindex.html', 'fileindex.html']
  @values[:html_files] = static_files + (@files+@classes).map{|f| f.path }
  
  outfile = @outputdir + @project_name
  debug_msg "  rendering #{outfile}"
  self.render_template( templatefile, binding(), outfile )
end