Handles the mapping of a file’s information to HTML. In reality, a file corresponds to a
TopLevel object, containing modules, classes, and top-level
methods. In theory it could contain attributes and aliases, but we
ignore these for now.
# File rdoc/generator.rb, line 683
def initialize(context, options, file_dir)
super context, options
@values = {}
if options.all_one_file
@path = filename_to_label
else
@path = http_url(file_dir)
end
@name = @context.file_relative_name
collect_methods
AllReferences.add(name, self)
context.viewer = self
end
# File rdoc/generator.rb, line 809
def <=>(other)
self.name <=> other.name
end
# File rdoc/generator.rb, line 790
def file_attribute_values
full_path = @context.file_absolute_name
short_name = ::File.basename full_path
@values["title"] = CGI.escapeHTML("File: #{short_name} [#{@options.title}]")
if @context.diagram then
@values["diagram"] = diagram_reference(@context.diagram)
end
@values["short_name"] = CGI.escapeHTML(short_name)
@values["full_path"] = CGI.escapeHTML(full_path)
@values["dtm_modified"] = @context.file_stat.mtime.to_s
if @options.webcvs then
@values["cvsurl"] = cvs_url @options.webcvs, @values["full_path"]
end
end
# File rdoc/generator.rb, line 705
def filename_to_label
@context.file_relative_name.gsub(/%|\/|\?|\#/) do
('%%%x' % $&[0]).unpack('C')
end
end
# File rdoc/generator.rb, line 701
def http_url(file_dir)
::File.join file_dir, "#{@context.file_relative_name.tr '.', '_'}.html"
end
# File rdoc/generator.rb, line 719
def value_hash
file_attribute_values
add_table_of_sections
@values["charset"] = @options.charset
@values["href"] = path
@values["style_url"] = style_url(path, @options.css)
if @context.comment
d = markup(@context.comment)
@values["description"] = d if d.size > 0
end
ml = build_method_summary_list
@values["methods"] = ml unless ml.empty?
il = build_include_list(@context)
@values["includes"] = il unless il.empty?
rl = build_requires_list(@context)
@values["requires"] = rl unless rl.empty?
if @options.promiscuous
file_context = nil
else
file_context = @context
end
@values["sections"] = @context.sections.map do |section|
secdata = {
"sectitle" => section.title,
"secsequence" => section.sequence,
"seccomment" => markup(section.comment)
}
cl = build_class_list(0, @context, section, file_context)
secdata["classlist"] = cl unless cl.empty?
mdl = build_method_detail_list(section)
secdata["method_list"] = mdl unless mdl.empty?
al = build_alias_summary_list(section)
secdata["aliases"] = al unless al.empty?
co = build_constants_summary_list(section)
secdata["constants"] = co unless co.empty?
secdata
end
@values
end
# File rdoc/generator.rb, line 774
def write_on(f, file_list, class_list, method_list, overrides = {})
value_hash
@values['file_list'] = file_list
@values['class_list'] = class_list
@values['method_list'] = method_list
@values.update overrides
template = RDoc::TemplatePage.new(@template::BODY,
@template::FILE_PAGE,
@template::METHOD_LIST)
template.write_html_on(f, @values)
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.