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| %>
<% end %>
<% end %>
<% if sections["attributes"] then %>
#{@attribute_list_heading}
<% sections["attributes"].each do |attributes| %>
<% if attributes["rw"] then %>
[<%= attributes["rw"] %>]
<% end %>
<% unless attributes["rw"] then %>
<% end %>
<%= attributes["name"] %>
<%= attributes["a_desc"] %>
<% end %><%# sections["attributes"] %>
<% 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 %>