Generators::HtmlClass

Wrap a ClassModule context


Wrap a ClassModule context

Attributes

path[R]

Public Class Methods

new(context, html_file, prefix, options) click to toggle source
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 549
def initialize(context, html_file, prefix, options)
    super(context, options)
    @@c_seq  = @@c_seq.succ
    @c_seq   = @@c_seq
    @html_file = html_file
    @is_module = context.is_module?
    @values    = {}

    context.viewer = self

    @path = http_url(context.full_name, prefix)

    collect_methods

    AllReferences.add(name, self)
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 736
def <=>(other)
    self.name <=> other.name
end
aref() click to toggle source
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 580
def aref
    @c_seq
end
build_attribute_list(section) click to toggle source
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 666
def build_attribute_list(section)
    atts = @context.attributes.sort
    res = []
    atts.each do |att|
        next unless att.section == section
        if att.visibility == :public || att.visibility == :protected || @options.show_all
            entry = {
                "name"   => CGI.escapeHTML(att.name), 
                "rw"     => att.rw, 
                "a_desc" => markup(att.comment, true)
            }
            unless att.visibility == :public || att.visibility == :protected
                entry["rw"] << "-"
            end
            res << entry
        end
    end
    res
end
class_attribute_values() click to toggle source
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 686
def class_attribute_values
    h_name = CGI.escapeHTML(name)

    @values["classmod"]  = @is_module ? "Module" : "Class"
    @values["title"]     = "#{@values['classmod']}: #{h_name}"

    c = @context
    c = c.parent while c and !c.diagram
    if c && c.diagram
        @values["diagram"] = diagram_reference(c.diagram)
    end

    @values["full_name"] = h_name
    @values["class_seq"] = seq
    parent_class = @context.superclass

    if parent_class
        @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"] = 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"] = 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
full_name() click to toggle source
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 598
def full_name
    @context.full_name
end
http_url(full_name, prefix) click to toggle source

return the relative file name to store this class in, which is also its url

# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 568
def http_url(full_name, prefix)
    path = full_name.dup
    if path['<<']
        path.gsub!(/<<\s*(\w*)/) { "from-#$1" }
    end
    File.join(prefix, path.split("::")) + ".html"
end
name() click to toggle source
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 594
def name
    @context.full_name.gsub("#{scope}::", '')
end
parent_name() click to toggle source
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 602
def parent_name
    @context.parent.full_name
end
scope() click to toggle source
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 584
def scope
    a = @context.full_name.split("::")
    if a.length > 1
        a.pop
        a.join("::")
    else
        "" 
    end
end
seq() click to toggle source
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 576
def seq
    @c_seq
end
value_hash() click to toggle source
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 614
def value_hash
    class_attribute_values
    add_table_of_sections

    @values["charset"] = @options.charset
    @values["style_url"] = style_url(path, @options.css)

    # Convert README to html
    unless File.exist?('files/README.html')
      File.open('files/README.html', 'w') do |file|
        file << markup(File.read(File.expand_path(@options.main_page)))
      end
    end

    d = markup(@context.comment)
    @values["description"] = d unless d.empty?

    ml = build_method_summary_list
    @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
write_on(f) click to toggle source
# File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 606
def write_on(f)
    value_hash
    template = TemplatePage.new(RDoc::Page::BODY,
    RDoc::Page::CLASS_PAGE,
    RDoc::Page::METHOD_LIST)
    template.write_html_on(f, @values)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.