Class: Generators::HTMLGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc/generators/template/html/resh/resh.rb

Instance Method Summary collapse

Instance Method Details

#gen_an_index(collection, title, template, filename) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/rdoc/generators/template/html/resh/resh.rb', line 86

def gen_an_index(collection, title, template, filename)
	res = []
	collection.sort.each do |f|
		if f.document_self
			res << { "href" => f.path, "name" => f.index_name }
		end
	end

	values = {
		"entries"    => res,
		'list_title' => CGI.escapeHTML(title),
		'index_url'  => main_url,
		'charset'    => @options.charset,
		'style_url'  => style_url('', @options.css),
	}
	begin
		File.open(filename, "w") {|f|
			f << ERB.new(File.read($tmpl+RDoc::Page.const_get(title.upcase))).result(binding)
		}
	rescue NameError
	end
end

#gen_main_indexObject



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/rdoc/generators/template/html/resh/resh.rb', line 109

def gen_main_index
	return unless defined? RDoc::Page::INDEX
	File.open("index.html", "w") do |f|
		values = {
			"initial_page" => main_url,
			'title'        => CGI.escapeHTML(@options.title),
			'charset'      => @options.charset,
			'style_url'  => style_url('', @options.css),
		}
		if @options.inline_source
			values['inline_source'] = true
		end
		f << ERB.new(File.read($tmpl+RDoc::Page::INDEX)).result(binding)
	end
end

#generate(*args) ⇒ Object



73
74
75
76
# File 'lib/rdoc/generators/template/html/resh/resh.rb', line 73

def generate(*args)
	@options.instance_eval "@inline_source = true"
	orig_generate(*args)
end

#generate_xmlObject



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/rdoc/generators/template/html/resh/resh.rb', line 125

def generate_xml
	values = { 
		'charset' => @options.charset,
		'files'   => gen_into(@files),
		'classes' => gen_into(@classes),
		'title'   => CGI.escapeHTML(@options.title),
	}

	# this method is defined in the template file
	write_extra_pages if defined? write_extra_pages

	if @options.op_name
		opfile = File.open(@options.op_name, "w")
	else
		opfile = $stdout
	end
	File.open(opfile, "w") {|f|
		f << ERB.new(File.read($tmpl+RDoc::Page::ONE_PAGE)).result(binding)
	}
end

#orig_generateObject



72
# File 'lib/rdoc/generators/template/html/resh/resh.rb', line 72

alias :orig_generate :generate

#write_style_sheetObject

TemplatePage をつかっているのをぬきだしてきたやつ



79
80
81
82
83
84
# File 'lib/rdoc/generators/template/html/resh/resh.rb', line 79

def write_style_sheet
	return unless defined? RDoc::Page::STYLE
	File.open(::Generators::CSS_NAME, "w") {|f|
		f << ERB.new(File.read($tmpl+RDoc::Page::STYLE)).result(binding)
	}
end