Reorganize RDoc generators

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2008-01-13 03:02:49 +00:00
parent 513d0ca7f6
commit 937b7ab8b5
15 changed files with 258 additions and 251 deletions

View File

@ -1,3 +1,7 @@
Sun Jan 13 12:01:32 2008 Eric Hodel <drbrain@segment7.net>
* lib/rdoc/generators*: Reorganize RDoc generators.
Sun Jan 13 11:41:11 2008 NARUSE, Yui <naruse@ruby-lang.org> Sun Jan 13 11:41:11 2008 NARUSE, Yui <naruse@ruby-lang.org>
* encoding.c (ENCINDEX_EUC_JP, ENCINDEX_SJIS): removed. * encoding.c (ENCINDEX_EUC_JP, ENCINDEX_SJIS): removed.

View File

@ -1,9 +1,25 @@
require 'cgi' require 'cgi'
require 'rdoc'
require 'rdoc/options' require 'rdoc/options'
require 'rdoc/markup/simple_markup' require 'rdoc/markup/simple_markup'
require 'rdoc/template' require 'rdoc/template'
module RDoc; end # HACK module RDoc::Generators
module RDoc::Generators; end ##
# Name of sub-direcory that holds file descriptions
FILE_DIR = "files"
##
# Name of sub-direcory that holds class descriptions
CLASS_DIR = "classes"
##
# Name of the RDoc CSS file
CSS_NAME = "rdoc-style.css"
end

View File

@ -1,6 +1,6 @@
require 'rdoc/generators/html_generator' require 'rdoc/generators/html'
class RDoc::Generators::CHMGenerator < RDoc::Generators::HTMLGenerator class RDoc::Generators::CHM < RDoc::Generators::HTML
HHC_PATH = "c:/Program Files/HTML Help Workshop/hhc.exe" HHC_PATH = "c:/Program Files/HTML Help Workshop/hhc.exe"
@ -52,7 +52,7 @@ class RDoc::Generators::CHMGenerator < RDoc::Generators::HTMLGenerator
# files that go to make up the help. # files that go to make up the help.
def create_project_file def create_project_file
template = RDoc::TemplatePage.new RDoc::Page::HPP_FILE template = RDoc::TemplatePage.new @template::HPP_FILE
values = { "title" => @options.title, "opname" => @op_name } values = { "title" => @options.title, "opname" => @op_name }
files = [] files = []
@files.each do |f| @files.each do |f|
@ -90,13 +90,13 @@ class RDoc::Generators::CHMGenerator < RDoc::Generators::HTMLGenerator
end end
values = { "contents" => contents } values = { "contents" => contents }
template = RDoc::TemplatePage.new RDoc::Page::CONTENTS template = RDoc::TemplatePage.new @template::CONTENTS
File.open("contents.hhc", "w") do |f| File.open("contents.hhc", "w") do |f|
template.write_html_on(f, values) template.write_html_on(f, values)
end end
values = { "index" => index } values = { "index" => index }
template = RDoc::TemplatePage.new RDoc::Page::CHM_INDEX template = RDoc::TemplatePage.new @template::CHM_INDEX
File.open("index.hhk", "w") do |f| File.open("index.hhk", "w") do |f|
template.write_html_on(f, values) template.write_html_on(f, values)
end end

View File

@ -1,14 +1,26 @@
module RDoc::Page require 'rdoc/generators/chm'
require 'rdoc/generators/html/html'
require "rdoc/generators/template/html/html" module RDoc::Generators::CHM::CHM
# This is a nasty little hack, but hhc doesn't support the <?xml HTML = RDoc::Generators::HTML::HTML
# tag, so...
BODY.sub!(/<\?xml.*\?>/, '') INDEX = HTML::INDEX
SRC_PAGE.sub!(/<\?xml.*\?>/, '')
HPP_FILE = %{ CLASS_INDEX = HTML::CLASS_INDEX
CLASS_PAGE = HTML::CLASS_PAGE
FILE_INDEX = HTML::FILE_INDEX
FILE_PAGE = HTML::FILE_PAGE
METHOD_INDEX = HTML::METHOD_INDEX
METHOD_LIST = HTML::METHOD_LIST
FR_INDEX_BODY = HTML::FR_INDEX_BODY
# This is a nasty little hack, but hhc doesn't support the <?xml tag, so...
BODY = HTML::BODY.sub!(/<\?xml.*\?>/, '')
SRC_PAGE = HTML::SRC_PAGE.sub!(/<\?xml.*\?>/, '')
HPP_FILE = <<-EOF
[OPTIONS] [OPTIONS]
Auto Index = Yes Auto Index = Yes
Compatibility=1.1 or later Compatibility=1.1 or later
@ -23,9 +35,9 @@ Title=<%= values["title"] %>
<% values["all_html_files"].each do |all_html_files| %> <% values["all_html_files"].each do |all_html_files| %>
<%= all_html_files["html_file_name"] %> <%= all_html_files["html_file_name"] %>
<% end # values["all_html_files"] %> <% end # values["all_html_files"] %>
} EOF
CONTENTS = %{ CONTENTS = <<-EOF
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML> <HTML>
<HEAD> <HEAD>
@ -57,9 +69,9 @@ CONTENTS = %{
<% end # values["contents"] %> <% end # values["contents"] %>
</UL> </UL>
</BODY></HTML> </BODY></HTML>
} EOF
CHM_INDEX = %{ CHM_INDEX = <<-EOF
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML> <HTML>
<HEAD> <HEAD>
@ -80,7 +92,7 @@ CHM_INDEX = %{
<% end # values["index"] %> <% end # values["index"] %>
</UL> </UL>
</BODY></HTML> </BODY></HTML>
} EOF
end end

View File

@ -5,21 +5,6 @@ require 'rdoc/markup/simple_markup/to_html'
module RDoc::Generators module RDoc::Generators
##
# Name of sub-direcory that holds file descriptions
FILE_DIR = "files"
##
# Name of sub-direcory that holds class descriptions
CLASS_DIR = "classes"
##
# Name of the RDoc CSS file
CSS_NAME = "rdoc-style.css"
## ##
# Build a hash of all items that can be cross-referenced. # Build a hash of all items that can be cross-referenced.
# This is used when we output required and included names: # This is used when we output required and included names:
@ -126,7 +111,7 @@ module RDoc::Generators
if path[0,1] == '#' # is this meaningful? if path[0,1] == '#' # is this meaningful?
url = path url = path
else else
url = HTMLGenerator.gen_url(@from_path, path) url = HTML.gen_url(@from_path, path)
end end
end end
@ -235,7 +220,7 @@ module RDoc::Generators
if %r{^(https?:/)?/} =~ css_name if %r{^(https?:/)?/} =~ css_name
return css_name return css_name
else else
return HTMLGenerator.gen_url(path, css_name) return HTML.gen_url(path, css_name)
end end
end end
@ -268,6 +253,9 @@ module RDoc::Generators
def initialize(context, options) def initialize(context, options)
@context = context @context = context
@options = options @options = options
# HACK ugly
@template = options.template_class
end end
## ##
@ -285,7 +273,7 @@ module RDoc::Generators
if @options.all_one_file if @options.all_one_file
"#" + path "#" + path
else else
HTMLGenerator.gen_url(from_path, path) HTML.gen_url(from_path, path)
end end
end end
@ -513,7 +501,7 @@ module RDoc::Generators
end end
def url(target) def url(target)
HTMLGenerator.gen_url(path, target) HTML.gen_url(path, target)
end end
def aref_to(target) def aref_to(target)
@ -618,9 +606,9 @@ module RDoc::Generators
def write_on(f) def write_on(f)
value_hash value_hash
template = RDoc::TemplatePage.new(RDoc::Page::BODY, template = RDoc::TemplatePage.new(@template::BODY,
RDoc::Page::CLASS_PAGE, @template::CLASS_PAGE,
RDoc::Page::METHOD_LIST) @template::METHOD_LIST)
template.write_html_on(f, @values) template.write_html_on(f, @values)
end end
@ -851,9 +839,11 @@ module RDoc::Generators
def write_on(f) def write_on(f)
value_hash value_hash
template = RDoc::TemplatePage.new(RDoc::Page::BODY,
RDoc::Page::FILE_PAGE, template = RDoc::TemplatePage.new(@template::BODY,
RDoc::Page::METHOD_LIST) @template::FILE_PAGE,
@template::METHOD_LIST)
template.write_html_on(f, @values) template.write_html_on(f, @values)
end end
@ -903,6 +893,10 @@ module RDoc::Generators
@context = context @context = context
@html_class = html_class @html_class = html_class
@options = options @options = options
# HACK ugly
@template = options.template_class
@@seq = @@seq.succ @@seq = @@seq.succ
@seq = @@seq @seq = @@seq
@@all_methods << self @@all_methods << self
@ -913,7 +907,7 @@ module RDoc::Generators
@source_code = markup_code(ts) @source_code = markup_code(ts)
unless @options.inline_source unless @options.inline_source
@src_url = create_source_code_file(@source_code) @src_url = create_source_code_file(@source_code)
@img_url = HTMLGenerator.gen_url(path, 'source.png') @img_url = HTML.gen_url(path, 'source.png')
end end
end end
@ -928,7 +922,7 @@ module RDoc::Generators
if @options.all_one_file if @options.all_one_file
"#" + path "#" + path
else else
HTMLGenerator.gen_url(from_path, path) HTML.gen_url(from_path, path)
end end
end end
@ -988,7 +982,6 @@ module RDoc::Generators
def params def params
# params coming from a call-seq in 'C' will start with the # params coming from a call-seq in 'C' will start with the
# method name # method name
p = @context.params
if p !~ /^\w/ if p !~ /^\w/
p = @context.params.gsub(/\s*\#.*/, '') p = @context.params.gsub(/\s*\#.*/, '')
p = p.tr("\n", " ").squeeze(" ") p = p.tr("\n", " ").squeeze(" ")
@ -1016,7 +1009,7 @@ module RDoc::Generators
FileUtils.mkdir_p(meth_path) FileUtils.mkdir_p(meth_path)
file_path = File.join(meth_path, @seq) + ".html" file_path = File.join(meth_path, @seq) + ".html"
template = RDoc::TemplatePage.new(RDoc::Page::SRC_PAGE) template = RDoc::TemplatePage.new(@template::SRC_PAGE)
File.open(file_path, "w") do |f| File.open(file_path, "w") do |f|
values = { values = {
'title' => CGI.escapeHTML(index_name), 'title' => CGI.escapeHTML(index_name),
@ -1026,7 +1019,7 @@ module RDoc::Generators
} }
template.write_html_on(f, values) template.write_html_on(f, values)
end end
HTMLGenerator.gen_url(path, file_path) HTML.gen_url(path, file_path)
end end
def self.all_methods def self.all_methods
@ -1149,7 +1142,7 @@ module RDoc::Generators
# #
# HTML is generated using the Template class. # HTML is generated using the Template class.
class HTMLGenerator class HTML
include MarkUp include MarkUp
@ -1183,9 +1176,9 @@ module RDoc::Generators
HtmlMethod.reset HtmlMethod.reset
if options.all_one_file if options.all_one_file
HTMLGeneratorInOne.new(options) HTMLInOne.new(options)
else else
HTMLGenerator.new(options) HTML.new(options)
end end
end end
@ -1226,12 +1219,17 @@ module RDoc::Generators
def load_html_template def load_html_template
template = @options.template template = @options.template
unless template =~ %r{/|\\}
template = File.join("rdoc/generators/template", unless template =~ %r{/|\\} then
template = File.join("rdoc/generators",
@options.generator.key, template) @options.generator.key, template)
end end
require template require template
extend RDoc::Page
@template = self.class.const_get @options.template.upcase
@options.template_class = @template
rescue LoadError rescue LoadError
$stderr.puts "Could not find HTML template '#{template}'" $stderr.puts "Could not find HTML template '#{template}'"
exit 99 exit 99
@ -1241,10 +1239,20 @@ module RDoc::Generators
# Write out the style sheet used by the main frames # Write out the style sheet used by the main frames
def write_style_sheet def write_style_sheet
template = RDoc::TemplatePage.new(RDoc::Page::STYLE) return unless @template.constants.include? :STYLE or
unless @options.css @template.constants.include? 'STYLE'
template = RDoc::TemplatePage.new @template::STYLE
unless @options.css then
File.open(CSS_NAME, "w") do |f| File.open(CSS_NAME, "w") do |f|
values = { "fonts" => RDoc::Page::FONTS } values = {}
if @template.constants.include? :FONTS or
@template.constants.include? 'FONTS' then
values["fonts"] = @template::FONTS
end
template.write_html_on(f, values) template.write_html_on(f, values)
end end
end end
@ -1316,25 +1324,21 @@ module RDoc::Generators
end end
def gen_file_index def gen_file_index
gen_an_index(@files, 'Files', gen_an_index @files, 'Files', @template::FILE_INDEX, "fr_file_index.html"
RDoc::Page::FILE_INDEX,
"fr_file_index.html")
end end
def gen_class_index def gen_class_index
gen_an_index(@classes, 'Classes', gen_an_index(@classes, 'Classes', @template::CLASS_INDEX,
RDoc::Page::CLASS_INDEX,
"fr_class_index.html") "fr_class_index.html")
end end
def gen_method_index def gen_method_index
gen_an_index(HtmlMethod.all_methods, 'Methods', gen_an_index(HtmlMethod.all_methods, 'Methods', @template::METHOD_INDEX,
RDoc::Page::METHOD_INDEX,
"fr_method_index.html") "fr_method_index.html")
end end
def gen_an_index(collection, title, template, filename) def gen_an_index(collection, title, template, filename)
template = RDoc::TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template) template = RDoc::TemplatePage.new @template::FR_INDEX_BODY, template
res = [] res = []
collection.sort.each do |f| collection.sort.each do |f|
if f.document_self if f.document_self
@ -1362,7 +1366,7 @@ module RDoc::Generators
# line. # line.
def gen_main_index def gen_main_index
template = RDoc::TemplatePage.new RDoc::Page::INDEX template = RDoc::TemplatePage.new @template::INDEX
open 'index.html', 'w' do |f| open 'index.html', 'w' do |f|
classes = @classes.sort.map { |klass| klass.value_hash } classes = @classes.sort.map { |klass| klass.value_hash }
@ -1413,7 +1417,7 @@ module RDoc::Generators
end end
class HTMLGeneratorInOne < HTMLGenerator class HTMLInOne < HTML
def initialize(*args) def initialize(*args)
super super
@ -1476,7 +1480,7 @@ module RDoc::Generators
# this method is defined in the template file # this method is defined in the template file
write_extra_pages if defined? write_extra_pages write_extra_pages if defined? write_extra_pages
template = RDoc::TemplatePage.new(RDoc::Page::ONE_PAGE) template = RDoc::TemplatePage.new @template::ONE_PAGE
if @options.op_name if @options.op_name
opfile = File.open(@options.op_name, "w") opfile = File.open(@options.op_name, "w")

View File

@ -1,15 +1,16 @@
module RDoc require 'rdoc/generators/html'
module Page require 'rdoc/generators/html/html'
module RDoc::Generators::HTML::HEFSS
FONTS = "Verdana, Arial, Helvetica, sans-serif" FONTS = "Verdana, Arial, Helvetica, sans-serif"
STYLE = %{ STYLE = <<-EOF
body,p { font-family: Verdana, Arial, Helvetica, sans-serif; body,p { font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000040; background: #BBBBBB; color: #000040; background: #BBBBBB;
} }
td { font-family: Verdana, Arial, Helvetica, sans-serif; td { font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000040; color: #000040;
} }
@ -21,7 +22,7 @@ td { font-family: Verdana, Arial, Helvetica, sans-serif;
.big-title-font { color: white; .big-title-font { color: white;
font-family: Verdana, Arial, Helvetica, sans-serif; font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: large; font-size: large;
height: 50px} height: 50px}
.small-title-font { color: purple; .small-title-font { color: purple;
@ -104,13 +105,9 @@ td { font-family: Verdana, Arial, Helvetica, sans-serif;
.srcbut { float: right } .srcbut { float: right }
} EOF
BODY = <<-EOF
############################################################################
BODY = %{
<html><head> <html><head>
<title><%= values["title"] %></title> <title><%= values["title"] %></title>
<meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>">
@ -198,11 +195,9 @@ BODY = %{
</body> </body>
</html> </html>
} EOF
############################################################################### FILE_PAGE = <<-EOF
FILE_PAGE = <<_FILE_PAGE_
<table width="100%"> <table width="100%">
<tr class="title-row"> <tr class="title-row">
<td><table width="100%"><tr> <td><table width="100%"><tr>
@ -224,11 +219,9 @@ FILE_PAGE = <<_FILE_PAGE_
</td></tr></table></td> </td></tr></table></td>
</tr> </tr>
</table><br /> </table><br />
_FILE_PAGE_ EOF
################################################################### CLASS_PAGE = <<-EOF
CLASS_PAGE = %{
<table width="100%" border="0" cellspacing="0"> <table width="100%" border="0" cellspacing="0">
<tr class="title-row"> <tr class="title-row">
<td class="big-title-font"> <td class="big-title-font">
@ -265,11 +258,9 @@ CLASS_PAGE = %{
</td> </td>
</tr> </tr>
</table><br /> </table><br />
} EOF
################################################################### METHOD_LIST = <<-EOF
METHOD_LIST = %{
<% if values["includes"] then %> <% if values["includes"] then %>
<div class="tablesubsubtitle">Uses</div><br /> <div class="tablesubsubtitle">Uses</div><br />
<div class="name-list"> <div class="name-list">
@ -308,14 +299,9 @@ METHOD_LIST = %{
<% end %> <% end %>
<% end # values["sections"] %> <% end # values["sections"] %>
<% end %> <% end %>
} EOF
=begin SRC_PAGE = <<-EOF
=end
########################## Source code ##########################
SRC_PAGE = %{
<html> <html>
<head><title><%= values["title"] %></title> <head><title><%= values["title"] %></title>
<meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>">
@ -339,15 +325,13 @@ SRC_PAGE = %{
<pre><%= values["code"] %></pre> <pre><%= values["code"] %></pre>
</body> </body>
</html> </html>
} EOF
########################## Index ################################ FR_INDEX_BODY = %{
FR_INDEX_BODY = %{
<%= template_include %> <%= template_include %>
} }
FILE_INDEX = %{ FILE_INDEX = <<-EOF
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>">
@ -355,10 +339,10 @@ FILE_INDEX = %{
<!-- <!--
body { body {
background-color: #bbbbbb; background-color: #bbbbbb;
font-family: #{FONTS}; font-family: #{FONTS};
font-size: 11px; font-size: 11px;
font-style: normal; font-style: normal;
line-height: 14px; line-height: 14px;
color: #000040; color: #000040;
} }
div.banner { div.banner {
@ -383,12 +367,12 @@ div.banner {
<a href="<%= entries["href"] %>"><%= entries["name"] %></a><br /> <a href="<%= entries["href"] %>"><%= entries["name"] %></a><br />
<% end # values["entries"] %> <% end # values["entries"] %>
</body></html> </body></html>
} EOF
CLASS_INDEX = FILE_INDEX CLASS_INDEX = FILE_INDEX
METHOD_INDEX = FILE_INDEX METHOD_INDEX = FILE_INDEX
INDEX = %{ INDEX = <<-EOF
<html> <html>
<head> <head>
<title><%= values["title"] %></title> <title><%= values["title"] %></title>
@ -414,17 +398,17 @@ INDEX = %{
</frameset> </frameset>
</html> </html>
} EOF
# and a blank page to use as a target # Blank page to use as a target
BLANK = %{ BLANK = %{
<html><body bgcolor="#BBBBBB"></body></html> <html><body bgcolor="#BBBBBB"></body></html>
} }
def write_extra_pages def write_extra_pages
template = TemplatePage.new(BLANK) template = TemplatePage.new(BLANK)
File.open("blank.html", "w") { |f| template.write_html_on(f, {}) } File.open("blank.html", "w") { |f| template.write_html_on(f, {}) }
end end
end end
end

View File

@ -1,4 +1,7 @@
# require 'rdoc/generators/html'
require 'rdoc/generators/html/one_page_html'
##
# = CSS2 RDoc HTML template # = 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 Transitional and dictates a
@ -17,14 +20,12 @@
# a copy of this license, visit http://creativecommons.org/licenses/by/1.0/ or # a copy of this license, visit http://creativecommons.org/licenses/by/1.0/ or
# send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California # send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
# 94305, USA. # 94305, USA.
#
module RDoc module RDoc::Generators::HTML::HTML
module Page
FONTS = "Verdana,Arial,Helvetica,sans-serif" FONTS = "Verdana,Arial,Helvetica,sans-serif"
STYLE = <<-EOF STYLE = <<-EOF
body { body {
font-family: Verdana,Arial,Helvetica,sans-serif; font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 90%; font-size: 90%;
@ -239,13 +240,14 @@ EOF
### H E A D E R T E M P L A T E ### H E A D E R T E M P L A T E
##################################################################### #####################################################################
XHTML_PREAMBLE = %{<?xml version="1.0" encoding="<%= values["charset"] %>"?> XHTML_PREAMBLE = <<-EOF
<?xml version="1.0" encoding="<%= values["charset"] %>"?>
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
} EOF
HEADER = XHTML_PREAMBLE + <<-EOF HEADER = XHTML_PREAMBLE + <<-EOF
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<title><%= values["title"] %></title> <title><%= values["title"] %></title>
@ -288,33 +290,32 @@ HEADER = XHTML_PREAMBLE + <<-EOF
<body> <body>
EOF EOF
##################################################################### #####################################################################
### C O N T E X T C O N T E N T T E M P L A T E ### C O N T E X T C O N T E N T T E M P L A T E
##################################################################### #####################################################################
CONTEXT_CONTENT = %{ CONTEXT_CONTENT = %{
} }
##################################################################### #####################################################################
### F O O T E R T E M P L A T E ### F O O T E R T E M P L A T E
##################################################################### #####################################################################
FOOTER = <<-EOF
FOOTER = <<-EOF
<div id="validator-badges"> <div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div> </div>
</body> </body>
</html> </html>
EOF EOF
##################################################################### #####################################################################
### F I L E P A G E H E A D E R T E M P L A T E ### F I L E P A G E H E A D E R T E M P L A T E
##################################################################### #####################################################################
FILE_PAGE = <<-EOF FILE_PAGE = <<-EOF
<div id="fileHeader"> <div id="fileHeader">
<h1><%= values["short_name"] %></h1> <h1><%= values["short_name"] %></h1>
<table class="header-table"> <table class="header-table">
@ -332,14 +333,13 @@ FILE_PAGE = <<-EOF
</tr> </tr>
</table> </table>
</div> </div>
EOF EOF
##################################################################### #####################################################################
### C L A S S P A G E H E A D E R T E M P L A T E ### C L A S S P A G E H E A D E R T E M P L A T E
##################################################################### #####################################################################
CLASS_PAGE = <<-EOF CLASS_PAGE = <<-EOF
<div id="classHeader"> <div id="classHeader">
<table class="header-table"> <table class="header-table">
<tr class="top-aligned-row"> <tr class="top-aligned-row">
@ -381,14 +381,13 @@ CLASS_PAGE = <<-EOF
<% end %> <% end %>
</table> </table>
</div> </div>
EOF EOF
##################################################################### #####################################################################
### M E T H O D L I S T T E M P L A T E ### M E T H O D L I S T T E M P L A T E
##################################################################### #####################################################################
METHOD_LIST = <<-EOF METHOD_LIST = <<-EOF
<div id="contextContent"> <div id="contextContent">
<% if values["diagram"] then %> <% if values["diagram"] then %>
@ -419,7 +418,7 @@ METHOD_LIST = <<-EOF
<div id="contents-list"> <div id="contents-list">
<h3 class="section-bar">Contents</h3> <h3 class="section-bar">Contents</h3>
<ul> <ul>
<% values["toc"].each do |toc| $stderr.puts({ :toc => toc }.inspect) %> <% values["toc"].each do |toc| %>
<li><a href="#<%= values["href"] %>"><%= values["secname"] %></a></li> <li><a href="#<%= values["href"] %>"><%= values["secname"] %></a></li>
<% end # values["toc"] %> <% end # values["toc"] %>
</ul> </ul>
@ -601,14 +600,13 @@ METHOD_LIST = <<-EOF
</div> </div>
<% end %> <% end %>
<% end # values["sections"] %> <% end # values["sections"] %>
EOF EOF
##################################################################### #####################################################################
### B O D Y T E M P L A T E ### B O D Y T E M P L A T E
##################################################################### #####################################################################
BODY = HEADER + %{ BODY = HEADER + %{
<%= template_include %> <!-- banner header --> <%= template_include %> <!-- banner header -->
@ -620,13 +618,11 @@ BODY = HEADER + %{
} + FOOTER } + FOOTER
##################################################################### #####################################################################
### S O U R C E C O D E T E M P L A T E ### S O U R C E C O D E T E M P L A T E
##################################################################### #####################################################################
SRC_PAGE = XHTML_PREAMBLE + <<-EOF SRC_PAGE = XHTML_PREAMBLE + <<-EOF
<html> <html>
<head> <head>
<title><%= values["title"] %></title> <title><%= values["title"] %></title>
@ -637,18 +633,18 @@ SRC_PAGE = XHTML_PREAMBLE + <<-EOF
<pre><%= values["code"] %></pre> <pre><%= values["code"] %></pre>
</body> </body>
</html> </html>
EOF EOF
##################################################################### #####################################################################
### I N D E X F I L E T E M P L A T E S ### I N D E X F I L E T E M P L A T E S
##################################################################### #####################################################################
FR_INDEX_BODY = %{ FR_INDEX_BODY = %{
<%= template_include %> <%= template_include %>
} }
FILE_INDEX = XHTML_PREAMBLE + %{ FILE_INDEX = XHTML_PREAMBLE + <<-EOF
<!-- <!--
<%= values["list_title"] %> <%= values["list_title"] %>
@ -672,12 +668,13 @@ FILE_INDEX = XHTML_PREAMBLE + %{
</div> </div>
</body> </body>
</html> </html>
} EOF
CLASS_INDEX = FILE_INDEX CLASS_INDEX = FILE_INDEX
METHOD_INDEX = FILE_INDEX METHOD_INDEX = FILE_INDEX
INDEX = %{<?xml version="1.0" encoding="<%= values["charset"] %>"?> INDEX = <<-EOF
<?xml version="1.0" encoding="<%= values["charset"] %>"?>
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
@ -701,11 +698,7 @@ INDEX = %{<?xml version="1.0" encoding="<%= values["charset"] %>"?>
<frame src="<%= values["initial_page"] %>" name="docwin" /> <frame src="<%= values["initial_page"] %>" name="docwin" />
</frameset> </frameset>
</html> </html>
} EOF
end
end # module Page
end # class RDoc
require 'rdoc/generators/template/html/one_page_html'

View File

@ -1,11 +1,11 @@
module RDoc require 'rdoc/generators/html'
module Page
module RDoc::Generators::HTML::KILMER
FONTS = "Verdana, Arial, Helvetica, sans-serif" FONTS = "Verdana, Arial, Helvetica, sans-serif"
STYLE = %{ STYLE = <<-EOF
body,td,p { font-family: <%= values["fonts"] %>; body,td,p { font-family: <%= values["fonts"] %>;
color: #000040; color: #000040;
} }
@ -15,11 +15,11 @@ body,td,p { font-family: <%= values["fonts"] %>;
color: #000010; color: #000010;
} }
.big-title-font { .big-title-font {
color: black; color: black;
font-weight: bold; font-weight: bold;
font-family: <%= values["fonts"] %>; font-family: <%= values["fonts"] %>;
font-size: large; font-size: large;
height: 60px; height: 60px;
padding: 10px 3px 10px 3px; padding: 10px 3px 10px 3px;
} }
@ -31,7 +31,7 @@ body,td,p { font-family: <%= values["fonts"] %>;
.aqua { color: black } .aqua { color: black }
.method-name, .attr-name { .method-name, .attr-name {
font-family: font-family: <%= values["fonts"] %>; font-family: font-family: <%= values["fonts"] %>;
font-weight: bold; font-weight: bold;
font-size: small; font-size: small;
margin-left: 20px; margin-left: 20px;
@ -67,7 +67,7 @@ body,td,p { font-family: <%= values["fonts"] %>;
font-weight: bold; font-weight: bold;
text-decoration: none; text-decoration: none;
color: #000033; color: #000033;
background-color: white; background-color: white;
} }
.srclink { .srclink {
@ -83,14 +83,9 @@ body,td,p { font-family: <%= values["fonts"] %>;
} }
.srcbut { float: right } .srcbut { float: right }
EOF
} BODY = <<-EOF
############################################################################
BODY = %{
<html><head> <html><head>
<title><%= values["title"] %></title> <title><%= values["title"] %></title>
<meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>">
@ -184,11 +179,9 @@ BODY = %{
</body> </body>
</html> </html>
} EOF
############################################################################### FILE_PAGE = <<-EOF
FILE_PAGE = <<_FILE_PAGE_
<table width="100%"> <table width="100%">
<tr class="title-row"> <tr class="title-row">
<td><table width="100%"><tr> <td><table width="100%"><tr>
@ -210,11 +203,9 @@ FILE_PAGE = <<_FILE_PAGE_
</td></tr></table></td> </td></tr></table></td>
</tr> </tr>
</table><br /> </table><br />
_FILE_PAGE_ EOF
################################################################### CLASS_PAGE = <<-EOF
CLASS_PAGE = %{
<table width="100%" border="0" cellspacing="0"> <table width="100%" border="0" cellspacing="0">
<tr class="title-row"> <tr class="title-row">
<td class="big-title-font"> <td class="big-title-font">
@ -251,11 +242,9 @@ CLASS_PAGE = %{
</td> </td>
</tr> </tr>
</table><br /> </table><br />
} EOF
################################################################### METHOD_LIST = <<-EOF
METHOD_LIST = %{
<% if values["includes"] then %> <% if values["includes"] then %>
<div class="tablesubsubtitle">Included modules</div><br /> <div class="tablesubsubtitle">Included modules</div><br />
<div class="name-list"> <div class="name-list">
@ -308,14 +297,9 @@ This method is also aliased as
<% end %> <% end %>
<% end # values["method_list"] %> <% end # values["method_list"] %>
<% end %> <% end %>
} EOF
=begin SRC_PAGE = <<-EOF
=end
########################## Source code ##########################
SRC_PAGE = %{
<html> <html>
<head><title><%= values["title"] %></title> <head><title><%= values["title"] %></title>
<meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>">
@ -339,31 +323,30 @@ SRC_PAGE = %{
<pre><%= values["code"] %></pre> <pre><%= values["code"] %></pre>
</body> </body>
</html> </html>
} EOF
########################## Index ################################ FR_INDEX_BODY = %{
FR_INDEX_BODY = %{
<%= template_include %> <%= template_include %>
} }
FILE_INDEX = %{ FILE_INDEX = <<-EOF
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>">
<style> <style>
<!-- <!--
body { body {
background-color: #ddddff; background-color: #ddddff;
font-family: #{FONTS}; font-family: #{FONTS};
font-size: 11px; font-size: 11px;
font-style: normal; font-style: normal;
line-height: 14px; line-height: 14px;
color: #000040; color: #000040;
} }
div.banner { div.banner {
background: #0000aa; background: #0000aa;
color: white; color: white;
padding: 1; padding: 1;
margin: 0; margin: 0;
font-size: 90%; font-size: 90%;
@ -372,7 +355,7 @@ div.banner {
text-align: center; text-align: center;
width: 100%; width: 100%;
} }
--> -->
</style> </style>
<base target="docwin"> <base target="docwin">
@ -383,12 +366,12 @@ div.banner {
<a href="<%= entries["href"] %>"><%= entries["name"] %></a><br /> <a href="<%= entries["href"] %>"><%= entries["name"] %></a><br />
<% end # values["entries"] %> <% end # values["entries"] %>
</body></html> </body></html>
} EOF
CLASS_INDEX = FILE_INDEX CLASS_INDEX = FILE_INDEX
METHOD_INDEX = FILE_INDEX METHOD_INDEX = FILE_INDEX
INDEX = %{ INDEX = <<-EOF
<html> <html>
<head> <head>
<title><%= values["title"] %></title> <title><%= values["title"] %></title>
@ -419,17 +402,17 @@ INDEX = %{
</frameset> </frameset>
</html> </html>
} EOF
# and a blank page to use as a target # A blank page to use as a target
BLANK = %{ BLANK = %{
<html><body bgcolor="white"></body></html> <html><body bgcolor="white"></body></html>
} }
def write_extra_pages def write_extra_pages
template = TemplatePage.new(BLANK) template = TemplatePage.new(BLANK)
File.open("blank.html", "w") { |f| template.write_html_on(f, {}) } File.open("blank.html", "w") { |f| template.write_html_on(f, {}) }
end end
end end
end

View File

@ -1,6 +1,8 @@
module RDoc::Page require 'rdoc/generators/html'
CONTENTS_XML = %{ module RDoc::Generators::HTML::ONE_PAGE_HTML
CONTENTS_XML = <<-EOF
<% if defined? classes and classes["description"] then %> <% if defined? classes and classes["description"] then %>
<%= classes["description"] %> <%= classes["description"] %>
<% end %> <% end %>
@ -72,11 +74,9 @@ CONTENTS_XML = %{
<% end %> <% end %>
<% end # classes["sections"] %> <% end # classes["sections"] %>
<% end %> <% end %>
} EOF
######################################################################## ONE_PAGE = %{
ONE_PAGE = %{
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <html>
<head> <head>

View File

@ -6,7 +6,7 @@ require 'rdoc/ri/reader'
require 'rdoc/ri/writer' require 'rdoc/ri/writer'
require 'rdoc/ri/descriptions' require 'rdoc/ri/descriptions'
class RDoc::Generators::RIGenerator class RDoc::Generators::RI
## ##
# Generators may need to return specific subclasses depending on the # Generators may need to return specific subclasses depending on the
@ -21,7 +21,7 @@ class RDoc::Generators::RIGenerator
end end
## ##
# Set up a new RIGenerator. # Set up a new RDoc::Generators::RI.
def initialize(options) #:not-new: def initialize(options) #:not-new:
@options = options @options = options

View File

@ -1,9 +1,9 @@
require 'rdoc/generators/html_generator' require 'rdoc/generators/html'
## ##
# Generate XML output as one big file # Generate XML output as one big file
class RDoc::Generators::XMLGenerator < RDoc::Generators::HTMLGenerator class RDoc::Generators::XML < RDoc::Generators::HTML
## ##
# Standard generator factory # Standard generator factory
@ -71,7 +71,7 @@ class RDoc::Generators::XMLGenerator < RDoc::Generators::HTMLGenerator
# this method is defined in the template file # this method is defined in the template file
write_extra_pages if defined? write_extra_pages write_extra_pages if defined? write_extra_pages
template = RDoc::TemplatePage.new(RDoc::Page::ONE_PAGE) template = RDoc::TemplatePage.new @template::ONE_PAGE
if @options.op_name if @options.op_name
opfile = File.open(@options.op_name, "w") opfile = File.open(@options.op_name, "w")

View File

@ -1,6 +1,8 @@
module RDoc::Page require 'rdoc/generators/xml'
CONTENTS_RDF = %{ module RDoc::Generators::XML::RDF
CONTENTS_RDF = <<-EOF
<% if defined? classes and classes["description"] then %> <% if defined? classes and classes["description"] then %>
<description rd:parseType="Literal"> <description rd:parseType="Literal">
<%= classes["description"] %> <%= classes["description"] %>
@ -63,11 +65,11 @@ CONTENTS_RDF = %{
<!-- end method list --> <!-- end method list -->
<% end # classes["sections"] %> <% end # classes["sections"] %>
<% end %> <% end %>
} EOF
######################################################################## ########################################################################
ONE_PAGE = %{<?xml version="1.0" encoding="utf-8"?> ONE_PAGE = %{<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://pragprog.com/rdoc/rdoc.rdf#" xmlns="http://pragprog.com/rdoc/rdoc.rdf#"
xmlns:rd="http://pragprog.com/rdoc/rdoc.rdf#"> xmlns:rd="http://pragprog.com/rdoc/rdoc.rdf#">

View File

@ -1,6 +1,8 @@
module RDoc::Page require 'rdoc/generators/xml'
CONTENTS_XML = %{ module RDoc::Generators::XML::XML
CONTENTS_XML = <<-EOF
<% if defined? classes and classes["description"] then %> <% if defined? classes and classes["description"] then %>
<description> <description>
<%= classes["description"] %> <%= classes["description"] %>
@ -11,7 +13,7 @@ CONTENTS_XML = %{
<required-file-list> <required-file-list>
<% files["requires"].each do |requires| %> <% files["requires"].each do |requires| %>
<required-file name="<%= requires["name"] %>" <required-file name="<%= requires["name"] %>"
<% if requires["aref"] then %> <% if requires["aref"] then %>
href="<%= requires["aref"] %>" href="<%= requires["aref"] %>"
<% end %> <% end %>
/> />
@ -69,11 +71,9 @@ CONTENTS_XML = %{
</included-module-list> </included-module-list>
<% end %> <% end %>
</contents> </contents>
} EOF
######################################################################## ONE_PAGE = %{<?xml version="1.0" encoding="utf-8"?>
ONE_PAGE = %{<?xml version="1.0" encoding="utf-8"?>
<rdoc> <rdoc>
<file-list> <file-list>
<% values["files"].each do |files| %> <% values["files"].each do |files| %>
@ -91,7 +91,7 @@ ONE_PAGE = %{<?xml version="1.0" encoding="utf-8"?>
<<%= classes["classmod"] %> name="<%= classes["full_name"] %>" id="<%= classes["full_name"] %>"> <<%= classes["classmod"] %> name="<%= classes["full_name"] %>" id="<%= classes["full_name"] %>">
<classmod-info> <classmod-info>
<% if classes["infiles"] then %> <% if classes["infiles"] then %>
<infiles> <infiles>
<% classes["infiles"].each do |infiles| %> <% classes["infiles"].each do |infiles| %>
<infile><%= href infiles["full_path_url"], infiles["full_path"] %></infile> <infile><%= href infiles["full_path_url"], infiles["full_path"] %></infile>
<% end # classes["infiles"] %> <% end # classes["infiles"] %>

View File

@ -132,6 +132,13 @@ class RDoc::Options
attr_reader :template attr_reader :template
##
# Template class for file generation
#--
# HACK around dependencies in lib/rdoc/generators/html.rb
attr_accessor :template_class # :nodoc:
## ##
# Documentation title # Documentation title
@ -156,6 +163,7 @@ class RDoc::Options
@rdoc_include = [] @rdoc_include = []
@title = nil @title = nil
@template = nil @template = nil
@template_class = nil
@diagram = false @diagram = false
@fileboxes = false @fileboxes = false
@show_hash = false @show_hash = false
@ -379,6 +387,7 @@ Usage: #{opt.program_name} [options] [names...]
"Put all the output into a single file.") do |value| "Put all the output into a single file.") do |value|
@all_one_file = value @all_one_file = value
@inline_source = value if value @inline_source = value if value
@template = 'one_page_html'
end end
opt.separator nil opt.separator nil
@ -411,7 +420,7 @@ Usage: #{opt.program_name} [options] [names...]
opt.on("--quiet", "-q", opt.on("--quiet", "-q",
"Don't show progress as we parse.") do |value| "Don't show progress as we parse.") do |value|
@quite = value @quiet = value
end end
opt.separator nil opt.separator nil

View File

@ -68,11 +68,11 @@ module RDoc
File.directory? "#{d}/rdoc/generators" File.directory? "#{d}/rdoc/generators"
end.each do |dir| end.each do |dir|
Dir.entries("#{dir}/rdoc/generators").each do |gen| Dir.entries("#{dir}/rdoc/generators").each do |gen|
next unless /(\w+)_generator.rb$/ =~ gen next unless /(\w+)\.rb$/ =~ gen
type = $1 type = $1
unless GENERATORS.has_key? type unless GENERATORS.has_key? type
GENERATORS[type] = Generator.new("rdoc/generators/#{gen}", GENERATORS[type] = Generator.new("rdoc/generators/#{gen}",
"#{type.upcase}Generator".intern, "#{type.upcase}".intern,
type) type)
end end
end end