Wrap a ClassModule context
# File rdoc/generator.rb, line 487
def initialize(context, html_file, prefix, options)
super context, options
@html_file = html_file
@html_class = self
@is_module = context.module?
@values = {}
context.viewer = self
if options.all_one_file
@path = context.full_name
else
@path = http_url(context.full_name, prefix)
end
collect_methods
AllReferences.add(name, self)
end
# File rdoc/generator.rb, line 665
def <=>(other)
self.name <=> other.name
end
# File rdoc/generator.rb, line 592
def build_attribute_list(section)
@context.attributes.sort.map do |att|
next unless att.section == section
if att.visibility == :public or att.visibility == :protected or
@options.show_all then
entry = {
"name" => CGI.escapeHTML(att.name),
"rw" => att.rw,
"a_desc" => markup(att.comment, true)
}
unless att.visibility == :public or att.visibility == :protected then
entry["rw"] << "-"
end
entry
end
end.compact
end
# File rdoc/generator.rb, line 614
def class_attribute_values
h_name = CGI.escapeHTML(name)
@values["href"] = @path
@values["classmod"] = @is_module ? "Module" : "Class"
@values["title"] = "#{@values['classmod']}: #{h_name} [#{@options.title}]"
c = @context
c = c.parent while c and not c.diagram
if c and c.diagram then
@values["diagram"] = diagram_reference(c.diagram)
end
@values["full_name"] = h_name
if not @context.module? and @context.superclass then
parent_class = @context.superclass
@values["parent"] = CGI.escapeHTML(parent_class)
if parent_name
lookup = parent_name + "::" + parent_class
else
lookup = parent_class
end
parent_url = AllReferences[lookup] || AllReferences[parent_class]
if parent_url and parent_url.document_self
@values["par_url"] = aref_to(parent_url.path)
end
end
files = []
@context.in_files.each do |f|
res = {}
full_path = CGI.escapeHTML(f.file_absolute_name)
res["full_path"] = full_path
res["full_path_url"] = aref_to(f.viewer.path) if f.document_self
if @options.webcvs
res["cvsurl"] = cvs_url( @options.webcvs, full_path )
end
files << res
end
@values['infiles'] = files
end
Returns the relative file name to store this class in, which is also its url
# File rdoc/generator.rb, line 512
def http_url(full_name, prefix)
path = full_name.dup
path.gsub!(/<<\s*(\w*)/, 'from-\1') if path['<<']
::File.join(prefix, path.split("::")) + ".html"
end
# File rdoc/generator.rb, line 524
def parent_name
@context.parent.full_name
end
# File rdoc/generator.rb, line 548
def value_hash
class_attribute_values
add_table_of_sections
@values["charset"] = @options.charset
@values["style_url"] = style_url(path, @options.css)
d = markup(@context.comment)
@values["description"] = d unless d.empty?
ml = build_method_summary_list @path
@values["methods"] = ml unless ml.empty?
il = build_include_list @context
@values["includes"] = il unless il.empty?
@values["sections"] = @context.sections.map do |section|
secdata = {
"sectitle" => section.title,
"secsequence" => section.sequence,
"seccomment" => markup(section.comment),
}
al = build_alias_summary_list section
secdata["aliases"] = al unless al.empty?
co = build_constants_summary_list section
secdata["constants"] = co unless co.empty?
al = build_attribute_list section
secdata["attributes"] = al unless al.empty?
cl = build_class_list 0, @context, section
secdata["classlist"] = cl unless cl.empty?
mdl = build_method_detail_list section
secdata["method_list"] = mdl unless mdl.empty?
secdata
end
@values
end
# File rdoc/generator.rb, line 532
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::CLASS_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.