Wrap text
Report abuse
|
|
require 'rdoc/generators/html_generator'
require 'erb'
module Generators
class ERBGenerator
def initialize(options)
@options = options
@template_path = get_erb_template_path
@classes = RDoc::TopLevel.all_classes_and_modules
end
def self.for(options)
ERBGenerator.new(options)
end
def generate(top_levels)
@files = top_levels
if @options.op_name
opfile = File.open(@options.op_name, "w")
else
opfile = $stdout
end
opfile.write(parsed_erb_template(binding))
end
protected
def get_erb_template_path
path = File.join(File.dirname(__FILE__), "template/erb/#{@options.template}.rhtml")
return path if File.exists?(path)
$stderr.puts "Could not find RHTML template '#{path}'"
exit 99
end
def parsed_erb_template(binding)
template = ERB.new(File.open(@template_path, 'r').read)
template.result(binding)
end
end
class SimpleClass < ContextUser
end
end
|