From 858362e761a41e7d96efbcb9b38ae815b1e388d7 Mon Sep 17 00:00:00 2001 From: drbrain Date: Thu, 25 Sep 2008 02:43:03 +0000 Subject: Import RDoc 2.2.1 r185 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/generator/html/common.rb | 24 + lib/rdoc/generator/html/frameless.rb | 759 ++----------------------------- lib/rdoc/generator/html/hefss.rb | 358 ++------------- lib/rdoc/generator/html/html.rb | 383 +++++++++------- lib/rdoc/generator/html/kilmer.rb | 329 ++------------ lib/rdoc/generator/html/kilmerfactory.rb | 427 +++++++++++++++++ lib/rdoc/generator/html/one_page_html.rb | 11 +- 7 files changed, 790 insertions(+), 1501 deletions(-) create mode 100644 lib/rdoc/generator/html/common.rb create mode 100644 lib/rdoc/generator/html/kilmerfactory.rb (limited to 'lib/rdoc/generator/html') diff --git a/lib/rdoc/generator/html/common.rb b/lib/rdoc/generator/html/common.rb new file mode 100644 index 0000000000..b25f009a72 --- /dev/null +++ b/lib/rdoc/generator/html/common.rb @@ -0,0 +1,24 @@ +# +# The templates require further refactoring. In particular, +# * Some kind of HTML generation library should be used. +# +# Also, all of the templates require some TLC from a designer. +# +# Right now, this file contains some constants that are used by all +# of the templates. +# +module RDoc::Generator::HTML::Common + XHTML_STRICT_PREAMBLE = <<-EOF + +EOF + + XHTML_FRAME_PREAMBLE = <<-EOF + +EOF + + HTML_ELEMENT = <<-EOF + +EOF +end diff --git a/lib/rdoc/generator/html/frameless.rb b/lib/rdoc/generator/html/frameless.rb index 2af890ce04..0375fee313 100644 --- a/lib/rdoc/generator/html/frameless.rb +++ b/lib/rdoc/generator/html/frameless.rb @@ -1,15 +1,16 @@ -require 'rdoc/generator/html' -require 'rdoc/generator/html/one_page_html' +require 'rdoc/generator/html/html' ## # = CSS2 RDoc HTML template # -# This is a template for RDoc that uses XHTML 1.0 Transitional and dictates a +# This is a template for RDoc that uses XHTML 1.0 Strict and dictates a # bit more of the appearance of the output to cascading stylesheets than the # default. It was designed for clean inline code display, and uses DHTMl to # toggle the visbility of each method's source with each click on the '[source]' # link. # +# Frameless basically is the html template without frames. +# # == Authors # # * Michael Granger @@ -25,692 +26,47 @@ module RDoc::Generator::HTML::FRAMELESS FRAMELESS = true - FONTS = "Verdana,Arial,Helvetica,sans-serif" - - STYLE = <<-EOF -body { - font-family: #{FONTS}; - font-size: 90%; - margin: 0; - margin-left: 40px; - padding: 0; - background: white; -} - -h1, h2, h3, h4 { - margin: 0; - color: #efefef; - background: transparent; -} - -h1 { - font-size: 150%; -} - -h2,h3,h4 { - margin-top: 1em; -} - -:link, :visited { - background: #eef; - color: #039; - text-decoration: none; -} - -:link:hover, :visited:hover { - background: #039; - color: #eef; -} - -/* Override the base stylesheet's Anchor inside a table cell */ -td > :link, td > :visited { - background: transparent; - color: #039; - text-decoration: none; -} - -/* and inside a section title */ -.section-title > :link, .section-title > :visited { - background: transparent; - color: #eee; - text-decoration: none; -} - -/* === Structural elements =================================== */ - -.index { - margin: 0; - margin-left: -40px; - padding: 0; - font-size: 90%; -} - -.index :link, .index :visited { - margin-left: 0.7em; -} - -.index .section-bar { - margin-left: 0px; - padding-left: 0.7em; - background: #ccc; - font-size: small; -} - -#classHeader, #fileHeader { - width: auto; - color: white; - padding: 0.5em 1.5em 0.5em 1.5em; - margin: 0; - margin-left: -40px; - border-bottom: 3px solid #006; -} - -#classHeader :link, #fileHeader :link, -#classHeader :visited, #fileHeader :visited { - background: inherit; - color: white; -} - -#classHeader td, #fileHeader td { - background: inherit; - color: white; -} - -#fileHeader { - background: #057; -} - -#classHeader { - background: #048; -} - -.class-name-in-header { - font-size: 180%; - font-weight: bold; -} - -#bodyContent { - padding: 0 1.5em 0 1.5em; -} - -#description { - padding: 0.5em 1.5em; - background: #efefef; - border: 1px dotted #999; -} - -#description h1, #description h2, #description h3, -#description h4, #description h5, #description h6 { - color: #125; - background: transparent; -} - -#copyright { - color: #333; - background: #efefef; - font: 0.75em sans-serif; - margin-top: 5em; - margin-bottom: 0; - padding: 0.5em 2em; -} - -/* === Classes =================================== */ - -table.header-table { - color: white; - font-size: small; -} - -.type-note { - font-size: small; - color: #dedede; -} - -.xxsection-bar { - background: #eee; - color: #333; - padding: 3px; -} - -.section-bar { - color: #333; - border-bottom: 1px solid #999; - margin-left: -20px; -} - -.section-title { - background: #79a; - color: #eee; - padding: 3px; - margin-top: 2em; - margin-left: -30px; - border: 1px solid #999; -} - -.top-aligned-row { - vertical-align: top -} - -.bottom-aligned-row { - vertical-align: bottom -} - -/* --- Context section classes ----------------------- */ - -.context-row { } - -.context-item-name { - font-family: monospace; - font-weight: bold; - color: black; -} - -.context-item-value { - font-size: small; - color: #448; -} - -.context-item-desc { - color: #333; - padding-left: 2em; -} - -/* --- Method classes -------------------------- */ - -.method-detail { - background: #efefef; - padding: 0; - margin-top: 0.5em; - margin-bottom: 1em; - border: 1px dotted #ccc; -} - -.method-heading { - color: black; - background: #ccc; - border-bottom: 1px solid #666; - padding: 0.2em 0.5em 0 0.5em; -} - -.method-signature { - color: black; - background: inherit; -} - -.method-name { - font-weight: bold; -} - -.method-args { - font-style: italic; -} + FONTS = RDoc::Generator::HTML::HTML::FONTS -.method-description { - padding: 0 0.5em 0 0.5em; -} + STYLE = RDoc::Generator::HTML::HTML::STYLE -/* --- Source code sections -------------------- */ - -:link.source-toggle, :visited.source-toggle { - font-size: 90%; -} - -div.method-source-code { - background: #262626; - color: #ffdead; - margin: 1em; - padding: 0.5em; - border: 1px dashed #999; - overflow: hidden; -} - -div.method-source-code pre { - color: #ffdead; - overflow: hidden; -} - -/* --- Ruby keyword styles --------------------- */ - -.standalone-code { - background: #221111; - color: #ffdead; - overflow: hidden; -} - -.ruby-constant { - color: #7fffd4; - background: transparent; -} - -.ruby-keyword { - color: #00ffff; - background: transparent; -} - -.ruby-ivar { - color: #eedd82; - background: transparent; -} - -.ruby-operator { - color: #00ffee; - background: transparent; -} - -.ruby-identifier { - color: #ffdead; - background: transparent; -} - -.ruby-node { - color: #ffa07a; - background: transparent; -} - -.ruby-comment { - color: #b22222; - font-weight: bold; - background: transparent; -} - -.ruby-regexp { - color: #ffa07a; - background: transparent; -} - -.ruby-value { - color: #7fffd4; - background: transparent; -} - -EOF - - ## - # Header template - - XHTML_PREAMBLE = <<-EOF -"?> - - EOF - - HEADER = XHTML_PREAMBLE + <<-EOF - - - <%= values["title"] %> - " /> - - " type="text/css" media="screen" /> - - - - -EOF - - ## - # Context content template - - CONTEXT_CONTENT = %{ -} - - ## - # Footer template + HEADER = RDoc::Generator::HTML::HTML::HEADER FOOTER = <<-EOF
- - - +
EOF - ## - # File page header template - - FILE_PAGE = <<-EOF -
-

<%= values["short_name"] %>

- - - - - - - - - - - -
Path:<%= values["full_path"] %> -<% if values["cvsurl"] then %> -  (">CVS) -<% end %> -
Last Update:<%= values["dtm_modified"] %>
-
- EOF - - ## - # Class page header template - - CLASS_PAGE = <<-EOF -
- - - - - - - - - - - -<% if values["parent"] then %> - - - - -<% end %> -
<%= values["classmod"] %><%= values["full_name"] %>
In: -<% values["infiles"].each do |infiles| %> -<% if infiles["full_path_url"] then %> - "> -<% end %> - <%= infiles["full_path"] %> -<% if infiles["full_path_url"] then %> - -<% end %> -<% if infiles["cvsurl"] then %> -  (">CVS) -<% end %> -
-<% end %><%# values["infiles"] %> -
Parent: -<% if values["par_url"] then %> - "> -<% end %> - <%= values["parent"] %> -<% if values["par_url"] then %> - -<% end %> -
-
- EOF - - ## - # Method list template - - METHOD_LIST = <<-EOF - -
-<% 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["toc"] then %> -
-

Contents

- -<% end %> -
- -<% if values["methods"] then %> -
-

Methods

+ FILE_PAGE = RDoc::Generator::HTML::HTML::FILE_PAGE -
-<% values["methods"].each do |methods| %> - <%= href methods["aref"], methods["name"] %>   -<% end %><%# values["methods"] %> -
-
-<% end %> + CLASS_PAGE = RDoc::Generator::HTML::HTML::CLASS_PAGE -
- - - -<% 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 values["classlist"] then %> -
-

Classes and Modules

- - <%= values["classlist"] %> -
-<% end %> - -<% if values["constants"] then %> -
-

Constants

- -
- -<% values["constants"].each do |constants| %> - - - - -<% if values["desc"] then %> - - -<% end %> - -<% end %><%# values["constants"] %> -
<%= constants["name"] %>=<%= constants["value"] %> <%= constants["desc"] %>
-
-
-<% end %> - -<% if values["aliases"] then %> -
-

External Aliases

- -
- -<% values["aliases"].each do |aliases| $stderr.puts({ :aliases => aliases }.inspect) %> - - - - - -<% if values["desc"] then %> - - - - -<% end %> -<% end %><%# values["aliases"] %> -
<%= values["old_name"] %>-><%= values["new_name"] %>
 <%= values["desc"] %>
-
-
-<% end %> - - -<% if values["attributes"] then %> -
-

Attributes

- -
- -<% values["attributes"].each do |attributes| $stderr.puts({ :attributes => attributes }.inspect) %> - - -<% if values["rw"] then %> - -<% end %> -<% unless values["rw"] then %> - -<% end %> - - -<% end %><%# values["attributes"] %> -
<%= values["name"] %> [<%= values["rw"] %>]   <%= values["a_desc"] %>
-
-
-<% 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| %> -
" class="method-detail"> - "> - - - -
-<% if methods["m_desc"] then %> - <%= methods["m_desc"] %> -<% end %> -<% if methods["sourcecode"] then %> -

-source');return false;">[Source]

-
-source"> -
-<%= methods["sourcecode"] %>
-
-
-<% end %> -
-
- -<% end %><%# method_list["methods"] %> -<% end %> -<% end %><%# sections["method_list"] %> - -
-<% end %> -<% end %><%# values["sections"] %> - EOF - - ## - # Body template + METHOD_LIST = RDoc::Generator::HTML::HTML::METHOD_LIST BODY = HEADER + %{ @@ -724,72 +80,13 @@ EOF } + FOOTER - ## - # Source code template - - SRC_PAGE = XHTML_PREAMBLE + <<-EOF - - - <%= values["title"] %> - " /> - " type="text/css" media="screen" /> - - -
<%= values["code"] %>
- - - EOF - - ## - # Index file templates - - FR_INDEX_BODY = %{ -<%= template_include %> -} + SRC_PAGE = RDoc::Generator::HTML::HTML::SRC_PAGE - FILE_INDEX = XHTML_PREAMBLE + <<-EOF - - - <%= values["list_title"] %> - " /> - " type="text/css" /> - - - -
-

<%= values["list_title"] %>

-
-<% values["entries"].each do |entries| %> - "><%= entries["name"] %>
-<% end %><%# values["entries"] %> -
-
- - - EOF + FR_INDEX_BODY = RDoc::Generator::HTML::HTML::FR_INDEX_BODY - CLASS_INDEX = FILE_INDEX - METHOD_INDEX = FILE_INDEX + FILE_INDEX = RDoc::Generator::HTML::HTML::FILE_INDEX - INDEX = <<-EOF -"?> - - - - <%= values["title"] %> - " /> - - - - - - - " name="docwin" /> - - - EOF + CLASS_INDEX = RDoc::Generator::HTML::HTML::CLASS_INDEX + METHOD_INDEX = RDoc::Generator::HTML::HTML::METHOD_INDEX end - diff --git a/lib/rdoc/generator/html/hefss.rb b/lib/rdoc/generator/html/hefss.rb index e186a40384..540c23d869 100644 --- a/lib/rdoc/generator/html/hefss.rb +++ b/lib/rdoc/generator/html/hefss.rb @@ -1,16 +1,16 @@ require 'rdoc/generator/html' -require 'rdoc/generator/html/html' +require 'rdoc/generator/html/kilmerfactory' module RDoc::Generator::HTML::HEFSS FONTS = "Verdana, Arial, Helvetica, sans-serif" -STYLE = <<-EOF -body,p { font-family: Verdana, Arial, Helvetica, sans-serif; + CENTRAL_STYLE = <<-EOF +body,p { font-family: <%= values["fonts"] %>; color: #000040; background: #BBBBBB; } -td { font-family: Verdana, Arial, Helvetica, sans-serif; +td { font-family: <%= values["fonts"] %>; color: #000040; } @@ -21,16 +21,20 @@ td { font-family: Verdana, Arial, Helvetica, sans-serif; } .big-title-font { color: white; - font-family: Verdana, Arial, Helvetica, sans-serif; + font-family: <%= values["fonts"] %>; font-size: large; height: 50px} .small-title-font { color: purple; - font-family: Verdana, Arial, Helvetica, sans-serif; + font-family: <%= values["fonts"] %>; font-size: small; } .aqua { color: purple } +#diagram img { + border: 0; +} + .method-name, attr-name { font-family: monospace; font-weight: bold; } @@ -75,241 +79,6 @@ td { font-family: Verdana, Arial, Helvetica, sans-serif; color: #0000AA; } -.column-title { - font-size: medium; - font-weight: bold; - text_decoration: none; - padding: 3px 3px 3px 20px; - color: #3333CC; - } - -.variable-name { - font-family: monospace; - font-size: medium; - text_decoration: none; - padding: 3px 3px 3px 20px; - color: #0000AA; -} - -.row-name { - font-size: medium; - font-weight: medium; - font-family: monospace; - text_decoration: none; - padding: 3px 3px 3px 20px; -} - -.paramsig { - font-size: small; -} - -.srcbut { float: right } - - EOF - - BODY = <<-EOF - - <%= values["title"] %> - "> - " type="text/css" media="screen" /> - - - - -<%= template_include %> - -<% 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["sections"] then %> -<% values["sections"].each do |sections| %> -<% if sections["method_list"] then %> -<% sections["method_list"].each do |method_list| %> -<% if method_list["methods"] then %> - - -
Subroutines and Functions

-
-<% method_list["methods"].each do |methods| %> -" target="source"><%= methods["name"] %> -<% end %><%# values["methods"] %> -
-<% end %> -<% end %><%# values["method_list"] %> -<% end %> - -<% if sections["attributes"] then %> - - -
Arguments

- -<% sections["attributes"].each do |attributes| %> - -<% if attributes["rw"] then %> - -<% end %> -<% unless attributes["rw"] then %> - -<% end %> - - - -<% end %><%# values["attributes"] %> -
 [<%= attributes["rw"] %>] <%= attributes["name"] %><%= attributes["a_desc"] %>
-<% end %> -<% end %><%# values["sections"] %> -<% end %> - -<% if values["classlist"] then %> - - -
Modules

-<%= values["classlist"] %>
-<% end %> - - <%= template_include %> - - - - EOF - - FILE_PAGE = <<-EOF - - - - -
- -
File
<%= values["short_name"] %>
- - - - - - - - -
Path:<%= values["full_path"] %> -<% if values["cvsurl"] then %> -  (">CVS) -<% end %> -
Modified:<%= values["dtm_modified"] %>
-

- EOF - - CLASS_PAGE = <<-EOF - - - - - -
- <%= 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 %> -
-

- EOF - - METHOD_LIST = <<-EOF -<% if values["includes"] then %> -
Uses

-
-<% values["includes"].each do |includes| %> - <%= href includes["aref"], includes["name"] %> -<% end %><%# values["includes"] %> -
-<% end %> - -<% if values["sections"] then %> -<% values["sections"].each do |sections| %> -<% 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| %> - - -
-"> -<%= methods["name"] %><%= methods["params"] %> -<% if methods["codeurl"] then %> -" target="source" class="srclink">src -<% end %> -
-<% if method_list["m_desc"] then %> -
-<%= method_list["m_desc"] %> -
-<% end %> -<% end %><%# method_list["methods"] %> -<% end %> -<% end %><%# sections["method_list"] %> -<% end %> -<% end %><%# values["sections"] %> -<% end %> - EOF - - SRC_PAGE = <<-EOF - -<%= values["title"] %> -"> - - - -
<%= values["code"] %>
- - + +.srcbut { float: right } EOF - FR_INDEX_BODY = %{ -<%= template_include %> + INDEX_STYLE = <<-EOF +body { + background-color: #bbbbbb; + font-family: #{FONTS}; + font-size: 11px; + font-style: normal; + line-height: 14px; + color: #000040; } - FILE_INDEX = <<-EOF - - -"> - - - - - -<% values["entries"].each do |entries| %> -"><%= entries["name"] %>
-<% end %><%# values["entries"] %> - - EOF + FACTORY = RDoc::Generator::HTML:: + KilmerFactory.new(:central_css => CENTRAL_STYLE, + :index_css => INDEX_STYLE, + :method_list_heading => "Subroutines and Functions", + :class_and_module_list_heading => "Classes and Modules", + :attribute_list_heading => "Arguments") - CLASS_INDEX = FILE_INDEX - METHOD_INDEX = FILE_INDEX + STYLE = FACTORY.get_STYLE() - INDEX = <<-EOF - - - <%= values["title"] %> - "> - + METHOD_LIST = FACTORY.get_METHOD_LIST() + + BODY = FACTORY.get_BODY() + + FILE_PAGE = FACTORY.get_FILE_PAGE() - - - - - - - - " name="docwin"> - - - - <body bgcolor="#BBBBBB"> - Click <a href="html/index.html">here</a> for a non-frames - version of this page. - </body> - - + CLASS_PAGE = FACTORY.get_CLASS_PAGE() - - EOF + SRC_PAGE = FACTORY.get_SRC_PAGE() - # Blank page to use as a target - BLANK = %{ - -} + FR_INDEX_BODY = FACTORY.get_FR_INDEX_BODY() - def write_extra_pages - template = TemplatePage.new(BLANK) - File.open("blank.html", "w") { |f| template.write_html_on(f, {}) } - end + FILE_INDEX = FACTORY.get_FILE_INDEX() -end + CLASS_INDEX = FACTORY.get_CLASS_INDEX() + + METHOD_INDEX = FACTORY.get_METHOD_INDEX() + INDEX = FACTORY.get_INDEX() + + def self.write_extra_pages(values) + FACTORY.write_extra_pages(values) + end +end diff --git a/lib/rdoc/generator/html/html.rb b/lib/rdoc/generator/html/html.rb index 1ab90c6264..823d8056e7 100644 --- a/lib/rdoc/generator/html/html.rb +++ b/lib/rdoc/generator/html/html.rb @@ -1,15 +1,17 @@ require 'rdoc/generator/html' -require 'rdoc/generator/html/one_page_html' +require 'rdoc/generator/html/common' ## # = CSS2 RDoc HTML template # -# This is a template for RDoc that uses XHTML 1.0 Transitional and dictates a +# This is a template for RDoc that uses XHTML 1.0 Strict and dictates a # bit more of the appearance of the output to cascading stylesheets than the # default. It was designed for clean inline code display, and uses DHTMl to # toggle the visibility of each method's source with each click on the # '[source]' link. # +# This template *also* forms the basis of the frameless template. +# # == Authors # # * Michael Granger @@ -23,34 +25,54 @@ require 'rdoc/generator/html/one_page_html' module RDoc::Generator::HTML::HTML + include RDoc::Generator::HTML::Common + FONTS = "Verdana,Arial,Helvetica,sans-serif" STYLE = <<-EOF body { - font-family: Verdana,Arial,Helvetica,sans-serif; - font-size: 90%; - margin: 0; - margin-left: 40px; - padding: 0; - background: white; + font-family: #{FONTS}; + font-size: 90%; + margin: 0; + margin-left: 40px; + padding: 0; + background: white; + color: black; +} + +h1, h2, h3, h4 { + margin: 0; + background: transparent; +} + +h1 { + font-size: 150%; } -h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; } -h1 { font-size: 150%; } -h2,h3,h4 { margin-top: 1em; } +h2,h3,h4 { + margin-top: 1em; +} -a { background: #eef; color: #039; text-decoration: none; } -a:hover { background: #039; color: #eef; } +:link, :visited { + background: #eef; + color: #039; + text-decoration: none; +} + +:link:hover, :visited:hover { + background: #039; + color: #eef; +} /* Override the base stylesheet's Anchor inside a table cell */ -td > a { +td > :link, td > :visited { background: transparent; color: #039; text-decoration: none; } /* and inside a section title */ -.section-title > a { +.section-title > :link, .section-title > :visited { background: transparent; color: #eee; text-decoration: none; @@ -58,181 +80,255 @@ td > a { /* === Structural elements =================================== */ -div#index { - margin: 0; - margin-left: -40px; - padding: 0; - font-size: 90%; +.index { + margin: 0; + margin-left: -40px; + padding: 0; + font-size: 90%; } - -div#index a { - margin-left: 0.7em; +.index :link, .index :visited { + margin-left: 0.7em; } -div#index .section-bar { - margin-left: 0px; - padding-left: 0.7em; - background: #ccc; - font-size: small; +.index .section-bar { + margin-left: 0px; + padding-left: 0.7em; + background: #ccc; + font-size: small; } - -div#classHeader, div#fileHeader { - width: auto; - color: white; - padding: 0.5em 1.5em 0.5em 1.5em; - margin: 0; - margin-left: -40px; - border-bottom: 3px solid #006; +#classHeader, #fileHeader { + width: auto; + color: white; + padding: 0.5em 1.5em 0.5em 1.5em; + margin: 0; + margin-left: -40px; + border-bottom: 3px solid #006; } -div#classHeader a, div#fileHeader a { - background: inherit; - color: white; +#classHeader :link, #fileHeader :link, +#classHeader :visited, #fileHeader :visited { + background: inherit; + color: white; } -div#classHeader td, div#fileHeader td { - background: inherit; - color: white; +#classHeader td, #fileHeader td { + background: inherit; + color: white; } - -div#fileHeader { - background: #057; +#fileHeader { + background: #057; } -div#classHeader { - background: #048; +#classHeader { + background: #048; } - .class-name-in-header { font-size: 180%; font-weight: bold; } - -div#bodyContent { - padding: 0 1.5em 0 1.5em; +#bodyContent { + padding: 0 1.5em 0 1.5em; } -div#description { - padding: 0.5em 1.5em; - background: #efefef; - border: 1px dotted #999; +#description { + padding: 0.5em 1.5em; + background: #efefef; + border: 1px dotted #999; } -div#description h1,h2,h3,h4,h5,h6 { - color: #125;; - background: transparent; +#description h1, #description h2, #description h3, +#description h4, #description h5, #description h6 { + color: #125; + background: transparent; } -div#validator-badges { - text-align: center; +#validator-badges { + text-align: center; } -div#validator-badges img { border: 0; } -div#copyright { - color: #333; - background: #efefef; - font: 0.75em sans-serif; - margin-top: 5em; - margin-bottom: 0; - padding: 0.5em 2em; +#validator-badges img { + border: 0; } +#copyright { + color: #333; + background: #efefef; + font: 0.75em sans-serif; + margin-top: 5em; + margin-bottom: 0; + padding: 0.5em 2em; +} /* === Classes =================================== */ table.header-table { - color: white; - font-size: small; + color: white; + font-size: small; } .type-note { - font-size: small; - color: #DEDEDE; + font-size: small; + color: #dedede; } -.xxsection-bar { - background: #eee; - color: #333; - padding: 3px; +.section-bar { + color: #333; + border-bottom: 1px solid #999; + margin-left: -20px; } -.section-bar { - color: #333; - border-bottom: 1px solid #999; - margin-left: -20px; +.section-title { + background: #79a; + color: #eee; + padding: 3px; + margin-top: 2em; + margin-left: -30px; + border: 1px solid #999; } +.top-aligned-row { + vertical-align: top +} -.section-title { - background: #79a; - color: #eee; - padding: 3px; - margin-top: 2em; - margin-left: -30px; - border: 1px solid #999; +.bottom-aligned-row { + vertical-align: bottom } -.top-aligned-row { vertical-align: top } -.bottom-aligned-row { vertical-align: bottom } +#diagram img { + border: 0; +} /* --- Context section classes ----------------------- */ .context-row { } -.context-item-name { font-family: monospace; font-weight: bold; color: black; } -.context-item-value { font-size: small; color: #448; } -.context-item-desc { color: #333; padding-left: 2em; } + +.context-item-name { + font-family: monospace; + font-weight: bold; + color: black; +} + +.context-item-value { + font-size: small; + color: #448; +} + +.context-item-desc { + color: #333; + padding-left: 2em; +} /* --- Method classes -------------------------- */ + .method-detail { - background: #efefef; - padding: 0; - margin-top: 0.5em; - margin-bottom: 1em; - border: 1px dotted #ccc; + background: #efefef; + padding: 0; + margin-top: 0.5em; + margin-bottom: 1em; + border: 1px dotted #ccc; } + .method-heading { color: black; background: #ccc; border-bottom: 1px solid #666; padding: 0.2em 0.5em 0 0.5em; } -.method-signature { color: black; background: inherit; } -.method-name { font-weight: bold; } -.method-args { font-style: italic; } -.method-description { padding: 0 0.5em 0 0.5em; } + +.method-signature { + color: black; + background: inherit; +} + +.method-name { + font-weight: bold; +} + +.method-args { + font-style: italic; +} + +.method-description { + padding: 0 0.5em 0 0.5em; +} /* --- Source code sections -------------------- */ -a.source-toggle { font-size: 90%; } +:link.source-toggle, :visited.source-toggle { + font-size: 90%; +} + div.method-source-code { - background: #262626; - color: #ffdead; - margin: 1em; - padding: 0.5em; - border: 1px dashed #999; - overflow: hidden; + background: #262626; + color: #ffdead; + margin: 1em; + padding: 0.5em; + border: 1px dashed #999; + overflow: auto; } -div.method-source-code pre { color: #ffdead; overflow: hidden; } +div.method-source-code pre { + color: #ffdead; +} /* --- Ruby keyword styles --------------------- */ -.standalone-code { background: #221111; color: #ffdead; overflow: hidden; } - -.ruby-constant { color: #7fffd4; background: transparent; } -.ruby-keyword { color: #00ffff; background: transparent; } -.ruby-ivar { color: #eedd82; background: transparent; } -.ruby-operator { color: #00ffee; background: transparent; } -.ruby-identifier { color: #ffdead; background: transparent; } -.ruby-node { color: #ffa07a; background: transparent; } -.ruby-comment { color: #b22222; font-weight: bold; background: transparent; } -.ruby-regexp { color: #ffa07a; background: transparent; } -.ruby-value { color: #7fffd4; background: transparent; } +.standalone-code { + background: #221111; + color: #ffdead; + overflow: auto; +} + +.ruby-constant { + color: #7fffd4; + background: transparent; +} + +.ruby-keyword { + color: #00ffff; + background: transparent; +} + +.ruby-ivar { + color: #eedd82; + background: transparent; +} + +.ruby-operator { + color: #00ffee; + background: transparent; +} + +.ruby-identifier { + color: #ffdead; + background: transparent; +} + +.ruby-node { + color: #ffa07a; + background: transparent; +} + +.ruby-comment { + color: #b22222; + font-weight: bold; + background: transparent; +} + +.ruby-regexp { + color: #ffa07a; + background: transparent; +} + +.ruby-value { + color: #7fffd4; + background: transparent; +} EOF @@ -240,15 +336,7 @@ EOF ### H E A D E R T E M P L A T E ##################################################################### - XHTML_PREAMBLE = <<-EOF -"?> - - EOF - - HEADER = XHTML_PREAMBLE + <<-EOF - + HEADER = XHTML_STRICT_PREAMBLE + HTML_ELEMENT + <<-EOF <%= values["title"] %> " /> @@ -281,7 +369,7 @@ EOF } // Make codeblocks hidden by default - document.writeln( "" ) + document.writeln( " - - -
<%= values["code"] %>
- - EOF - FR_INDEX_BODY = %{ -<%= template_include %> -} - - FILE_INDEX = <<-EOF - - -"> - - - - - -<% values["entries"].each do |entries| %> -"><%= entries["name"] %>
-<% end %><%# values["entries"] %> - - EOF + FACTORY = RDoc::Generator::HTML:: + KilmerFactory.new(:central_css => CENTRAL_STYLE, + :index_css => INDEX_STYLE) - CLASS_INDEX = FILE_INDEX - METHOD_INDEX = FILE_INDEX + STYLE = FACTORY.get_STYLE() - INDEX = <<-EOF - - - <%= values["title"] %> - "> - + METHOD_LIST = FACTORY.get_METHOD_LIST() + + BODY = FACTORY.get_BODY() + + FILE_PAGE = FACTORY.get_FILE_PAGE() - - - - - - -<% if values["inline_source"] then %> - " name="docwin"> -<% end %> -<% unless values["inline_source"] then %> - - " name="docwin"> - - -<% end %> - - <body bgcolor="white"> - Click <a href="html/index.html">here</a> for a non-frames - version of this page. - </body> - - + CLASS_PAGE = FACTORY.get_CLASS_PAGE() - - EOF + SRC_PAGE = FACTORY.get_SRC_PAGE() - # A blank page to use as a target - BLANK = %{ - -} + FR_INDEX_BODY = FACTORY.get_FR_INDEX_BODY() - def write_extra_pages - template = TemplatePage.new(BLANK) - File.open("blank.html", "w") { |f| template.write_html_on(f, {}) } - end + FILE_INDEX = FACTORY.get_FILE_INDEX() -end + CLASS_INDEX = FACTORY.get_CLASS_INDEX() + METHOD_INDEX = FACTORY.get_METHOD_INDEX() + + INDEX = FACTORY.get_INDEX() + + def self.write_extra_pages(values) + FACTORY.write_extra_pages(values) + end +end diff --git a/lib/rdoc/generator/html/kilmerfactory.rb b/lib/rdoc/generator/html/kilmerfactory.rb new file mode 100644 index 0000000000..ef6f3f3b4d --- /dev/null +++ b/lib/rdoc/generator/html/kilmerfactory.rb @@ -0,0 +1,427 @@ +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 diff --git a/lib/rdoc/generator/html/one_page_html.rb b/lib/rdoc/generator/html/one_page_html.rb index c4dd95529d..51ae32351a 100644 --- a/lib/rdoc/generator/html/one_page_html.rb +++ b/lib/rdoc/generator/html/one_page_html.rb @@ -1,7 +1,10 @@ require 'rdoc/generator/html' +require 'rdoc/generator/html/common' module RDoc::Generator::HTML::ONE_PAGE_HTML + include RDoc::Generator::HTML::Common + CONTENTS_XML = <<-EOF <% if defined? classes and classes["description"] then %> <%= classes["description"] %> @@ -76,16 +79,14 @@ module RDoc::Generator::HTML::ONE_PAGE_HTML <% end %> EOF - ONE_PAGE = %{ - - + ONE_PAGE = XHTML_STRICT_PREAMBLE + HTML_ELEMENT + %{ <%= values["title"] %> " /> <% values["files"].each do |files| %> -

File: <%= files["short_name"] %>

+

File: "><%= files["short_name"] %>

@@ -97,7 +98,7 @@ module RDoc::Generator::HTML::ONE_PAGE_HTML

Classes

<% values["classes"].each do |classes| %> <% if classes["parent"] then %> -

<%= classes["classmod"] %> <%= classes["full_name"] %> < <%= href classes["par_url"], classes["parent"] %>

+

<%= classes["classmod"] %> "><%= classes["full_name"] %> < <%= href classes["par_url"], classes["parent"] %>

<% end %> <% unless classes["parent"] then %>

<%= classes["classmod"] %> <%= classes["full_name"] %>

-- cgit v1.2.3
Path:<%= files["full_path"] %>
Modified:<%= files["dtm_modified"] %>