require 'rdoc/generator/html' require 'rdoc/generator/html/common' # # This class generates Kilmer-style templates. Right now, # rdoc is shipped with two such templates: # * kilmer # * hefss # # Kilmer-style templates use frames. The left side of the page has # three frames stacked on top of each other: one lists # files, one lists classes, and one lists methods. If source code # is not inlined, an additional frame runs across the bottom of # the page and will be used to display method source code. # The central (and largest frame) display class and file # pages. # # The constructor of this class accepts a Hash containing stylistic # attributes. Then, a get_BLAH instance method of this class returns a # value for the template's BLAH constant. get_BODY, for instance, returns # the value of the template's BODY constant. # class RDoc::Generator::HTML::KilmerFactory include RDoc::Generator::HTML::Common # # The contents of the stylesheet that should be used for the # central frame (for the class and file pages). # # This must be specified in the Hash passed to the constructor. # attr_reader :central_css # # The contents of the stylesheet that should be used for the # index pages. # # This must be specified in the Hash passed to the constructor. # attr_reader :index_css # # The heading that should be displayed before listing methods. # # If not supplied, this defaults to "Methods". # attr_reader :method_list_heading # # The heading that should be displayed before listing classes and # modules. # # If not supplied, this defaults to "Classes and Modules". # attr_reader :class_and_module_list_heading # # The heading that should be displayed before listing attributes. # # If not supplied, this defaults to "Attributes". # attr_reader :attribute_list_heading # # ====Description: # This method constructs a KilmerFactory instance, which # can be used to build Kilmer-style template classes. # The +style_attributes+ argument is a Hash that contains the # values of the classes attributes (Symbols mapped to Strings). # # ====Parameters: # [style_attributes] # A Hash describing the appearance of the Kilmer-style. # def initialize(style_attributes) @central_css = style_attributes[:central_css] if(!@central_css) raise ArgumentError, "did not specify a value for :central_css" end @index_css = style_attributes[:index_css] if(!@index_css) raise ArgumentError, "did not specify a value for :index_css" end @method_list_heading = style_attributes[:method_list_heading] if(!@method_list_heading) @method_list_heading = "Methods" end @class_and_module_list_heading = style_attributes[:class_and_module_list_heading] if(!@class_and_module_list_heading) @class_and_module_list_heading = "Classes and Modules" end @attribute_list_heading = style_attributes[:attribute_list_heading] if(!@attribute_list_heading) @attribute_list_heading = "Attributes" end end def get_STYLE return @central_css end def get_METHOD_LIST return %{ <% if values["diagram"] then %>
<%= values["diagram"] %>
<% end %> <% if values["description"] then %>
<%= values["description"] %>
<% end %> <% if values["requires"] then %>
Required files

<% values["requires"].each do |requires| %> <%= href requires["aref"], requires["name"] %> <% end %><%# values["requires"] %>
<% end %> <% if values["methods"] then %>
#{@method_list_heading}

<% values["methods"].each do |methods| %> <%= href methods["aref"], methods["name"] %>, <% end %><%# values["methods"] %>
<% end %> <% if values["includes"] then %>
Included modules

<% values["includes"].each do |includes| %> <%= href includes["aref"], includes["name"] %> <% end %><%# values["includes"] %>
<% end %> <% values["sections"].each do |sections| %>
<% if sections["sectitle"] then %>

"><%= sections["sectitle"] %>

<% if sections["seccomment"] then %>
<%= sections["seccomment"] %>
<% end %> <% end %> <% if sections["attributes"] then %>
#{@attribute_list_heading}

<% sections["attributes"].each do |attributes| %> <% if attributes["rw"] then %> <% end %> <% unless attributes["rw"] then %> <% end %> <% end %><%# sections["attributes"] %>
 [<%= attributes["rw"] %>] <%= attributes["name"] %> <%= attributes["a_desc"] %>
<% end %> <% if sections["classlist"] then %>
#{@class_and_module_list_heading}

<%= sections["classlist"] %>
<% end %> <% if sections["method_list"] then %> <% sections["method_list"].each do |method_list| %> <% if method_list["methods"] then %>
<%= method_list["type"] %> <%= method_list["category"] %> methods
<% method_list["methods"].each do |methods| %>
"> <% if methods["callseq"] then %> <%= methods["callseq"] %> <% end %> <% unless methods["callseq"] then %> <%= methods["name"] %><%= methods["params"] %> <% end %> <% if methods["codeurl"] then %> " target="source" class="srclink">src <% end %>
<% if methods["m_desc"] then %>
<%= methods["m_desc"] %>
<% end %> <% if methods["aka"] then %>
This method is also aliased as <% methods["aka"].each do |aka| %> "><%= methods["name"] %> <% end %><%# methods["aka"] %>
<% end %> <% if methods["sourcecode"] then %>
<%= methods["sourcecode"] %>
<% end %> <% end %><%# method_list["methods"] %> <% end %> <% end %><%# sections["method_list"] %> <% end %> <% end %><%# values["sections"] %>
} end def get_BODY return XHTML_STRICT_PREAMBLE + HTML_ELEMENT + %{ <%= values["title"] %> " /> " type="text/css" media="screen" />
<%= template_include %> #{get_METHOD_LIST()}
} end def get_FILE_PAGE return %{
File
<%= values["short_name"] %>
Path: <%= values["full_path"] %> <% if values["cvsurl"] then %>  (">CVS) <% end %>
Modified: <%= values["dtm_modified"] %>

} end def get_CLASS_PAGE return %{
<%= values["classmod"] %>
<%= values["full_name"] %>
<% if values["parent"] then %> <% end %>
In: <% values["infiles"].each do |infiles| %> <%= href infiles["full_path_url"], infiles["full_path"] %> <% if infiles["cvsurl"] then %>  (">CVS) <% end %> <% end %><%# values["infiles"] %>
Parent: <% if values["par_url"] then %> " class="cyan"> <% end %> <%= values["parent"] %> <% if values["par_url"] then %> <% end %>

} end def get_SRC_PAGE return XHTML_STRICT_PREAMBLE + HTML_ELEMENT + %{ <%= values["title"] %> " /> " type="text/css" media="screen" />
<%= values["code"] %>
} end def get_FR_INDEX_BODY return %{<%= template_include %>} end def get_FILE_INDEX return XHTML_STRICT_PREAMBLE + HTML_ELEMENT + %{ <%= values["title"] %> " />
<% values["entries"].each do |entries| %> "><%= entries["name"] %>
<% end %><%# values["entries"] %>
} end def get_CLASS_INDEX return get_FILE_INDEX end def get_METHOD_INDEX return get_FILE_INDEX end def get_INDEX return XHTML_FRAME_PREAMBLE + HTML_ELEMENT + %{ <%= values["title"] %> " /> <% if values["inline_source"] then %> " name="docwin" /> <% end %> <% unless values["inline_source"] then %> " name="docwin" /> <% end %> } end def get_BLANK # This will be displayed in the source code frame before # any source code has been selected. return XHTML_STRICT_PREAMBLE + HTML_ELEMENT + %{ Source Code Frame <%= values["title_suffix"] %> " /> " type="text/css" media="screen" /> } end def write_extra_pages(values) template = RDoc::TemplatePage.new(get_BLANK()) File.open("blank.html", "w") { |f| template.write_html_on(f, values) } end end