diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rdoc/generators/chm_generator.rb | 8 | ||||
-rw-r--r-- | lib/rdoc/generators/template/chm/chm.rb | 45 | ||||
-rw-r--r-- | lib/rdoc/generators/template/html/hefss.rb | 194 | ||||
-rw-r--r-- | lib/rdoc/generators/template/html/html.rb | 350 | ||||
-rw-r--r-- | lib/rdoc/generators/template/html/kilmer.rb | 242 | ||||
-rw-r--r-- | lib/rdoc/generators/template/html/old_html.rb | 728 | ||||
-rw-r--r-- | lib/rdoc/generators/template/html/one_page_html.rb | 163 | ||||
-rw-r--r-- | lib/rdoc/generators/template/xml/rdf.rb | 135 | ||||
-rw-r--r-- | lib/rdoc/generators/template/xml/xml.rb | 141 | ||||
-rw-r--r-- | lib/rdoc/template.rb | 247 |
10 files changed, 680 insertions, 1573 deletions
diff --git a/lib/rdoc/generators/chm_generator.rb b/lib/rdoc/generators/chm_generator.rb index b4a5167a5..c3272c9af 100644 --- a/lib/rdoc/generators/chm_generator.rb +++ b/lib/rdoc/generators/chm_generator.rb @@ -27,8 +27,6 @@ class RDoc::Generators::CHMGenerator < RDoc::Generators::HTMLGenerator "\n\nYou can download a copy for free from:\n\n" << " http://msdn.microsoft.com/library/default.asp?" << "url=/library/en-us/htmlhelp/html/hwMicrosoftHTMLHelpDownloads.asp\n\n" - - exit 99 end ## @@ -54,7 +52,7 @@ class RDoc::Generators::CHMGenerator < RDoc::Generators::HTMLGenerator # files that go to make up the help. def create_project_file - template = TemplatePage.new(RDoc::Page::HPP_FILE) + template = RDoc::TemplatePage.new RDoc::Page::HPP_FILE values = { "title" => @options.title, "opname" => @op_name } files = [] @files.each do |f| @@ -92,13 +90,13 @@ class RDoc::Generators::CHMGenerator < RDoc::Generators::HTMLGenerator end values = { "contents" => contents } - template = TemplatePage.new(RDoc::Page::CONTENTS) + template = RDoc::TemplatePage.new RDoc::Page::CONTENTS File.open("contents.hhc", "w") do |f| template.write_html_on(f, values) end values = { "index" => index } - template = TemplatePage.new(RDoc::Page::CHM_INDEX) + template = RDoc::TemplatePage.new RDoc::Page::CHM_INDEX File.open("index.hhk", "w") do |f| template.write_html_on(f, values) end diff --git a/lib/rdoc/generators/template/chm/chm.rb b/lib/rdoc/generators/template/chm/chm.rb index 4a89c2652..193202341 100644 --- a/lib/rdoc/generators/template/chm/chm.rb +++ b/lib/rdoc/generators/template/chm/chm.rb @@ -1,5 +1,4 @@ -module RDoc -module Page +module RDoc::Page require "rdoc/generators/template/html/html" @@ -13,17 +12,17 @@ HPP_FILE = %{ [OPTIONS] Auto Index = Yes Compatibility=1.1 or later -Compiled file=%opname%.chm +Compiled file=<%= values["opname"] %>.chm Contents file=contents.hhc Full-text search=Yes Index file=index.hhk Language=0x409 English(United States) -Title=%title% +Title=<%= values["title"] %> [FILES] -START:all_html_files -%html_file_name% -END:all_html_files +<% values["all_html_files"].each do |all_html_files| %> +<%= all_html_files["html_file_name"] %> +<% end # values["all_html_files"] %> } CONTENTS = %{ @@ -39,28 +38,27 @@ CONTENTS = %{ <param name="ImageType" value="Folder"> </OBJECT> <UL> -START:contents +<% values["contents"].each do |contents| %> <LI> <OBJECT type="text/sitemap"> - <param name="Name" value="%c_name%"> - <param name="Local" value="%ref%"> + <param name="Name" value="<%= contents["c_name"] %>"> + <param name="Local" value="<%= contents["ref"] %>"> </OBJECT> -IF:methods +<% if contents["methods"] then %> <ul> -START:methods +<% contents["methods"].each do |methods| %> <LI> <OBJECT type="text/sitemap"> - <param name="Name" value="%name%"> - <param name="Local" value="%aref%"> + <param name="Name" value="<%= methods["name"] %>"> + <param name="Local" value="<%= methods["aref"] %>"> </OBJECT> -END:methods +<% end # contents["methods"] %> </ul> -ENDIF:methods +<% end %> </LI> -END:contents +<% end # values["contents"] %> </UL> </BODY></HTML> } - CHM_INDEX = %{ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <HTML> @@ -74,14 +72,15 @@ CHM_INDEX = %{ <param name="ImageType" value="Folder"> </OBJECT> <UL> -START:index +<% values["index"].each do |index| %> <LI> <OBJECT type="text/sitemap"> - <param name="Name" value="%name%"> - <param name="Local" value="%aref%"> + <param name="Name" value="<%= index["name"] %>"> + <param name="Local" value="<%= index["aref"] %>"> </OBJECT> -END:index +<% end # values["index"] %> </UL> </BODY></HTML> } + end -end + diff --git a/lib/rdoc/generators/template/html/hefss.rb b/lib/rdoc/generators/template/html/hefss.rb index e68ca8582..a7baac6fd 100644 --- a/lib/rdoc/generators/template/html/hefss.rb +++ b/lib/rdoc/generators/template/html/hefss.rb @@ -112,9 +112,9 @@ td { font-family: Verdana, Arial, Helvetica, sans-serif; BODY = %{ <html><head> - <title>%title%</title> - <meta http-equiv="Content-Type" content="text/html; charset=%charset%"> - <link rel="stylesheet" href="%style_url%" type="text/css" media="screen" /> + <title><%= values["title"] %></title> + <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> + <link rel="stylesheet" href="<%= values["style_url"] %>" type="text/css" media="screen" /> <script type="text/javascript" language="JavaScript"> <!-- function popCode(url) { @@ -125,68 +125,76 @@ BODY = %{ </head> <body bgcolor="#BBBBBB"> -!INCLUDE! <!-- banner header --> +<%= template_include %> <!-- banner header --> -IF:diagram +<% if values["diagram"] then %> <table width="100%"><tr><td align="center"> -%diagram% +<%= values["diagram"] %> </td></tr></table> -ENDIF:diagram +<% end %> -IF:description -<div class="description">%description%</div> -ENDIF:description +<% if values["description"] then %> +<div class="description"><%= values["description"] %></div> +<% end %> -IF:requires +<% if values["requires"] then %> <table cellpadding="5" width="100%"> <tr><td class="tablesubtitle">Required files</td></tr> </table><br /> <div class="name-list"> -START:requires -HREF:aref:name: -END:requires -ENDIF:requires +<% values["requires"].each do |requires| %> +<%= href requires["aref"], requires["name"] %> +<% end # values["requires"] %> +<% end %> </div> -IF:methods +<% 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 %> <table cellpadding="5" width="100%"> <tr><td class="tablesubtitle">Subroutines and Functions</td></tr> </table><br /> <div class="name-list"> -START:methods -HREF:aref:name:, -END:methods +<% method_list["methods"].each do |methods| %> +<a href="<%= methods["codeurl"] %>" target="source"><%= methods["name"] %></a> +<% end # values["methods"] %> </div> -ENDIF:methods +<% end %> +<% end # values["method_list"] %> +<% end %> -IF:attributes +<% if sections["attributes"] then %> <table cellpadding="5" width="100%"> <tr><td class="tablesubtitle">Arguments</td></tr> </table><br /> <table cellspacing="5"> -START:attributes +<% sections["attributes"].each do |attributes| %> <tr valign="top"> -IF:rw - <td align="center" class="attr-rw"> [%rw%] </td> -ENDIF:rw -IFNOT:rw +<% if attributes["rw"] then %> + <td align="center" class="attr-rw"> [<%= attributes["rw"] %>] </td> +<% end %> +<% unless attributes["rw"] then %> <td></td> -ENDIF:rw - <td class="attr-name">%name%</td> - <td>%a_desc%</td> +<% end %> + <td class="attr-name"><%= attributes["name"] %></td> + <td><%= attributes["a_desc"] %></td> </tr> -END:attributes +<% end # values["attributes"] %> </table> -ENDIF:attributes +<% end %> +<% end # values["sections"] %> +<% end %> -IF:classlist +<% if values["classlist"] then %> <table cellpadding="5" width="100%"> <tr><td class="tablesubtitle">Modules</td></tr> </table><br /> -%classlist%<br /> -ENDIF:classlist +<%= values["classlist"] %><br /> +<% end %> - !INCLUDE! <!-- method descriptions --> + <%= template_include %> <!-- method descriptions --> </body> </html> @@ -198,19 +206,19 @@ FILE_PAGE = <<_FILE_PAGE_ <table width="100%"> <tr class="title-row"> <td><table width="100%"><tr> - <td class="big-title-font" colspan="2"><font size="-3"><b>File</b><br /></font>%short_name%</td> + <td class="big-title-font" colspan="2"><font size="-3"><b>File</b><br /></font><%= values["short_name"] %></td> <td align="right"><table cellspacing="0" cellpadding="2"> <tr> <td class="small-title-font">Path:</td> - <td class="small-title-font">%full_path% -IF:cvsurl - (<a href="%cvsurl%"><acronym title="Concurrent Versioning System">CVS</acronym></a>) -ENDIF:cvsurl + <td class="small-title-font"><%= values["full_path"] %> +<% if values["cvsurl"] then %> + (<a href="<%= values["cvsurl"] %>"><acronym title="Concurrent Versioning System">CVS</acronym></a>) +<% end %> </td> </tr> <tr> <td class="small-title-font">Modified:</td> - <td class="small-title-font">%dtm_modified%</td> + <td class="small-title-font"><%= values["dtm_modified"] %></td> </tr> </table> </td></tr></table></td> @@ -224,35 +232,35 @@ CLASS_PAGE = %{ <table width="100%" border="0" cellspacing="0"> <tr class="title-row"> <td class="big-title-font"> - <font size="-3"><b>%classmod%</b><br /></font>%full_name% + <font size="-3"><b><%= values["classmod"] %></b><br /></font><%= values["full_name"] %> </td> <td align="right"> <table cellspacing="0" cellpadding="2"> <tr valign="top"> <td class="small-title-font">In:</td> <td class="small-title-font"> -START:infiles -HREF:full_path_url:full_path: -IF:cvsurl - (<a href="%cvsurl%"><acronym title="Concurrent Versioning System">CVS</acronym></a>) -ENDIF:cvsurl -END:infiles +<% values["infiles"].each do |infiles| %> +<%= href infiles["full_path_url"], infiles["full_path"] %> +<% if infiles["cvsurl"] then %> + (<a href="<%= infiles["cvsurl"] %>"><acronym title="Concurrent Versioning System">CVS</acronym></a>) +<% end %> +<% end # values["infiles"] %> </td> </tr> -IF:parent +<% if values["parent"] then %> <tr> <td class="small-title-font">Parent:</td> <td class="small-title-font"> -IF:par_url - <a href="%par_url%" class="cyan"> -ENDIF:par_url -%parent% -IF:par_url +<% if values["par_url"] then %> + <a href="<%= values["par_url"] %>" class="cyan"> +<% end %> +<%= values["parent"] %> +<% if values["par_url"] then %> </a> -ENDIF:par_url +<% end %> </td> </tr> -ENDIF:parent +<% end %> </table> </td> </tr> @@ -262,40 +270,44 @@ ENDIF:parent ################################################################### METHOD_LIST = %{ -IF:includes +<% if values["includes"] then %> <div class="tablesubsubtitle">Uses</div><br /> <div class="name-list"> -START:includes - <span class="method-name">HREF:aref:name:</span> -END:includes +<% values["includes"].each do |includes| %> + <span class="method-name"><%= href includes["aref"], includes["name"] %></span> +<% end # values["includes"] %> </div> -ENDIF:includes +<% end %> -IF:method_list -START:method_list -IF:methods +<% 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 %> <table cellpadding="5" width="100%"> -<tr><td class="tablesubtitle">%type% %category% methods</td></tr> +<tr><td class="tablesubtitle"><%= method_list["type"] %> <%= method_list["category"] %> methods</td></tr> </table> -START:methods +<% method_list["methods"].each do |methods| %> <table width="100%" cellspacing="0" cellpadding="5" border="0"> <tr><td class="methodtitle"> -<a name="%aref%"> -<b>%name%</b>%params% -IF:codeurl -<a href="%codeurl%" target="source" class="srclink">src</a> -ENDIF:codeurl +<a name="<%= methods["aref"] %>"> +<b><%= methods["name"] %></b><%= methods["params"] %> +<% if methods["codeurl"] then %> +<a href="<%= methods["codeurl"] %>" target="source" class="srclink">src</a> +<% end %> </a></td></tr> </table> -IF:m_desc +<% if method_list["m_desc"] then %> <div class="description"> -%m_desc% +<%= method_list["m_desc"] %> </div> -ENDIF:m_desc -END:methods -ENDIF:methods -END:method_list -ENDIF:method_list +<% end %> +<% end # method_list["methods"] %> +<% end %> +<% end # sections["method_list"] %> +<% end %> +<% end # values["sections"] %> +<% end %> } =begin @@ -305,8 +317,8 @@ ENDIF:method_list SRC_PAGE = %{ <html> -<head><title>%title%</title> -<meta http-equiv="Content-Type" content="text/html; charset=%charset%"> +<head><title><%= values["title"] %></title> +<meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> <style type="text/css"> .kw { color: #3333FF; font-weight: bold } .cmt { color: green; font-style: italic } @@ -324,7 +336,7 @@ SRC_PAGE = %{ </style> </head> <body bgcolor="#BBBBBB"> -<pre>%code%</pre> +<pre><%= values["code"] %></pre> </body> </html> } @@ -332,13 +344,13 @@ SRC_PAGE = %{ ########################## Index ################################ FR_INDEX_BODY = %{ -!INCLUDE! +<%= template_include %> } FILE_INDEX = %{ <html> <head> -<meta http-equiv="Content-Type" content="text/html; charset=%charset%"> +<meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> <style type="text/css"> <!-- body { @@ -360,16 +372,16 @@ div.banner { text-align: center; width: 100%; } - + --> </style> <base target="docwin"> </head> <body> -<div class="banner">%list_title%</div> -START:entries -<a href="%href%">%name%</a><br /> -END:entries +<div class="banner"><%= values["list_title"] %></div> +<% values["entries"].each do |entries| %> +<a href="<%= entries["href"] %>"><%= entries["name"] %></a><br /> +<% end # values["entries"] %> </body></html> } @@ -379,8 +391,8 @@ METHOD_INDEX = FILE_INDEX INDEX = %{ <html> <head> - <title>%title%</title> - <meta http-equiv="Content-Type" content="text/html; charset=%charset%"> + <title><%= values["title"] %></title> + <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> </head> <frameset cols="20%,*"> @@ -390,7 +402,7 @@ INDEX = %{ <frame src="fr_method_index.html" name="Subroutines and Functions"> </frameset> <frameset rows="80%,20%"> - <frame src="%initial_page%" name="docwin"> + <frame src="<%= values["initial_page"] %>" name="docwin"> <frame src="blank.html" name="source"> </frameset> <noframes> diff --git a/lib/rdoc/generators/template/html/html.rb b/lib/rdoc/generators/template/html/html.rb index 7f9e59946..528058382 100644 --- a/lib/rdoc/generators/template/html/html.rb +++ b/lib/rdoc/generators/template/html/html.rb @@ -24,7 +24,7 @@ module RDoc FONTS = "Verdana,Arial,Helvetica,sans-serif" -STYLE = %{ +STYLE = <<-EOF body { font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 90%; @@ -232,26 +232,26 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; } .ruby-comment { color: #b22222; font-weight: bold; background: transparent; } .ruby-regexp { color: #ffa07a; background: transparent; } .ruby-value { color: #7fffd4; background: transparent; } -} +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="%charset%"?> -<!DOCTYPE html +XHTML_PREAMBLE = %{<?xml version="1.0" encoding="<%= values["charset"] %>"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> } -HEADER = XHTML_PREAMBLE + %{ +HEADER = XHTML_PREAMBLE + <<-EOF <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> - <title>%title%</title> - <meta http-equiv="Content-Type" content="text/html; charset=%charset%" /> + <title><%= values["title"] %></title> + <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> - <link rel="stylesheet" href="%style_url%" type="text/css" media="screen" /> + <link rel="stylesheet" href="<%= values["style_url"] %>" type="text/css" media="screen" /> <script type="text/javascript"> // <![CDATA[ @@ -268,7 +268,7 @@ HEADER = XHTML_PREAMBLE + %{ return false; elemStyle = elem.style; - + if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else { @@ -277,16 +277,16 @@ HEADER = XHTML_PREAMBLE + %{ return true; } - + // Make codeblocks hidden by default document.writeln( "<style type=\\"text/css\\">div.method-source-code { display: none }</style>" ) - + // ]]> </script> </head> <body> -} +EOF ##################################################################### @@ -300,308 +300,308 @@ CONTEXT_CONTENT = %{ ##################################################################### ### F O O T E R T E M P L A T E ##################################################################### -FOOTER = %{ +FOOTER = <<-EOF <div id="validator-badges"> <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> </div> </body> </html> -} +EOF ##################################################################### ### F I L E P A G E H E A D E R T E M P L A T E ##################################################################### -FILE_PAGE = %{ +FILE_PAGE = <<-EOF <div id="fileHeader"> - <h1>%short_name%</h1> + <h1><%= values["short_name"] %></h1> <table class="header-table"> <tr class="top-aligned-row"> <td><strong>Path:</strong></td> - <td>%full_path% -IF:cvsurl - (<a href="%cvsurl%"><acronym title="Concurrent Versioning System">CVS</acronym></a>) -ENDIF:cvsurl + <td><%= values["full_path"] %> +<% if values["cvsurl"] then %> + (<a href="<%= values["cvsurl"] %>"><acronym title="Concurrent Versioning System">CVS</acronym></a>) +<% end %> </td> </tr> <tr class="top-aligned-row"> <td><strong>Last Update:</strong></td> - <td>%dtm_modified%</td> + <td><%= values["dtm_modified"] %></td> </tr> </table> </div> -} +EOF ##################################################################### ### 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 = %{ +CLASS_PAGE = <<-EOF <div id="classHeader"> <table class="header-table"> <tr class="top-aligned-row"> - <td><strong>%classmod%</strong></td> - <td class="class-name-in-header">%full_name%</td> + <td><strong><%= values["classmod"] %></strong></td> + <td class="class-name-in-header"><%= values["full_name"] %></td> </tr> <tr class="top-aligned-row"> <td><strong>In:</strong></td> <td> -START:infiles -IF:full_path_url - <a href="%full_path_url%"> -ENDIF:full_path_url - %full_path% -IF:full_path_url +<% values["infiles"].each do |infiles| %> +<% if infiles["full_path_url"] then %> + <a href="<%= infiles["full_path_url"] %>"> +<% end %> + <%= infiles["full_path"] %> +<% if infiles["full_path_url"] then %> </a> -ENDIF:full_path_url -IF:cvsurl - (<a href="%cvsurl%"><acronym title="Concurrent Versioning System">CVS</acronym></a>) -ENDIF:cvsurl +<% end %> +<% if infiles["cvsurl"] then %> + (<a href="<%= infiles["cvsurl"] %>"><acronym title="Concurrent Versioning System">CVS</acronym></a>) +<% end %> <br /> -END:infiles +<% end # values["infiles"] %> </td> </tr> -IF:parent +<% if values["parent"] then %> <tr class="top-aligned-row"> <td><strong>Parent:</strong></td> <td> -IF:par_url - <a href="%par_url%"> -ENDIF:par_url - %parent% -IF:par_url +<% if values["par_url"] then %> + <a href="<%= values["par_url"] %>"> +<% end %> + <%= values["parent"] %> +<% if values["par_url"] then %> </a> -ENDIF:par_url +<% end %> </td> </tr> -ENDIF:parent +<% end %> </table> </div> -} +EOF ##################################################################### ### M E T H O D L I S T T E M P L A T E ##################################################################### -METHOD_LIST = %{ +METHOD_LIST = <<-EOF <div id="contextContent"> -IF:diagram +<% if values["diagram"] then %> <div id="diagram"> - %diagram% + <%= values["diagram"] %> </div> -ENDIF:diagram +<% end %> -IF:description +<% if values["description"] then %> <div id="description"> - %description% + <%= values["description"] %> </div> -ENDIF:description +<% end %> -IF:requires +<% if values["requires"] then %> <div id="requires-list"> <h3 class="section-bar">Required files</h3> <div class="name-list"> -START:requires - HREF:aref:name: -END:requires +<% values["requires"].each do |requires| %> + <%= href requires["aref"], requires["name"] %> +<% end # values["requires"] %> </div> </div> -ENDIF:requires +<% end %> -IF:toc +<% if values["toc"] then %> <div id="contents-list"> <h3 class="section-bar">Contents</h3> <ul> -START:toc - <li><a href="#%href%">%secname%</a></li> -END:toc +<% values["toc"].each do |toc| $stderr.puts({ :toc => toc }.inspect) %> + <li><a href="#<%= values["href"] %>"><%= values["secname"] %></a></li> +<% end # values["toc"] %> </ul> -ENDIF:toc +<% end %> </div> -IF:methods +<% if values["methods"] then %> <div id="method-list"> <h3 class="section-bar">Methods</h3> <div class="name-list"> -START:methods - HREF:aref:name: -END:methods +<% values["methods"].each do |methods| %> + <%= href methods["aref"], methods["name"] %> +<% end # values["methods"] %> </div> </div> -ENDIF:methods +<% end %> </div> <!-- if includes --> -IF:includes +<% if values["includes"] then %> <div id="includes"> <h3 class="section-bar">Included Modules</h3> <div id="includes-list"> -START:includes - <span class="include-name">HREF:aref:name:</span> -END:includes +<% values["includes"].each do |includes| %> + <span class="include-name"><%= href includes["aref"], includes["name"] %></span> +<% end # values["includes"] %> </div> </div> -ENDIF:includes +<% end %> -START:sections +<% values["sections"].each do |sections| %> <div id="section"> -IF:sectitle - <h2 class="section-title"><a name="%secsequence%">%sectitle%</a></h2> -IF:seccomment +<% if sections["sectitle"] then %> + <h2 class="section-title"><a name="<%= sections["secsequence"] %>"><%= sections["sectitle"] %></a></h2> +<% if sections["seccomment"] then %> <div class="section-comment"> - %seccomment% - </div> -ENDIF:seccomment -ENDIF:sectitle + <%= sections["seccomment"] %> + </div> +<% end %> +<% end %> -IF:classlist +<% if values["classlist"] then %> <div id="class-list"> <h3 class="section-bar">Classes and Modules</h3> - %classlist% + <%= values["classlist"] %> </div> -ENDIF:classlist +<% end %> -IF:constants +<% if values["constants"] then %> <div id="constants-list"> <h3 class="section-bar">Constants</h3> <div class="name-list"> <table summary="Constants"> -START:constants +<% values["constants"].each do |constants| $stderr.puts({ :constants => constants }.inspect) %> <tr class="top-aligned-row context-row"> - <td class="context-item-name">%name%</td> + <td class="context-item-name"><%= values["name"] %></td> <td>=</td> - <td class="context-item-value">%value%</td> -IF:desc + <td class="context-item-value"><%= values["value"] %></td> +<% if values["desc"] then %> <td width="3em"> </td> - <td class="context-item-desc">%desc%</td> -ENDIF:desc + <td class="context-item-desc"><%= values["desc"] %></td> +<% end %> </tr> -END:constants +<% end # values["constants"] %> </table> </div> </div> -ENDIF:constants +<% end %> -IF:aliases +<% if values["aliases"] then %> <div id="aliases-list"> <h3 class="section-bar">External Aliases</h3> <div class="name-list"> <table summary="aliases"> -START:aliases +<% values["aliases"].each do |aliases| $stderr.puts({ :aliases => aliases }.inspect) %> <tr class="top-aligned-row context-row"> - <td class="context-item-name">%old_name%</td> + <td class="context-item-name"><%= values["old_name"] %></td> <td>-></td> - <td class="context-item-value">%new_name%</td> + <td class="context-item-value"><%= values["new_name"] %></td> </tr> -IF:desc +<% if values["desc"] then %> <tr class="top-aligned-row context-row"> <td> </td> - <td colspan="2" class="context-item-desc">%desc%</td> + <td colspan="2" class="context-item-desc"><%= values["desc"] %></td> </tr> -ENDIF:desc -END:aliases - </table> +<% end %> +<% end # values["aliases"] %> + </table> </div> </div> -ENDIF:aliases +<% end %> -IF:attributes +<% if values["attributes"] then %> <div id="attribute-list"> <h3 class="section-bar">Attributes</h3> <div class="name-list"> <table> -START:attributes +<% values["attributes"].each do |attributes| $stderr.puts({ :attributes => attributes }.inspect) %> <tr class="top-aligned-row context-row"> - <td class="context-item-name">%name%</td> -IF:rw - <td class="context-item-value"> [%rw%] </td> -ENDIF:rw -IFNOT:rw + <td class="context-item-name"><%= values["name"] %></td> +<% if values["rw"] then %> + <td class="context-item-value"> [<%= values["rw"] %>] </td> +<% end %> +<% unless values["rw"] then %> <td class="context-item-value"> </td> -ENDIF:rw - <td class="context-item-desc">%a_desc%</td> +<% end %> + <td class="context-item-desc"><%= values["a_desc"] %></td> </tr> -END:attributes +<% end # values["attributes"] %> </table> </div> </div> -ENDIF:attributes +<% end %> <!-- if method_list --> -IF:method_list +<% if sections["method_list"] then %> <div id="methods"> -START:method_list -IF:methods - <h3 class="section-bar">%type% %category% methods</h3> +<% sections["method_list"].each do |method_list| %> +<% if method_list["methods"] then %> + <h3 class="section-bar"><%= method_list["type"] %> <%= method_list["category"] %> methods</h3> -START:methods - <div id="method-%aref%" class="method-detail"> - <a name="%aref%"></a> +<% method_list["methods"].each do |methods| %> + <div id="method-<%= methods["aref"] %>" class="method-detail"> + <a name="<%= methods["aref"] %>"></a> <div class="method-heading"> -IF:codeurl - <a href="%codeurl%" target="Code" class="method-signature" - onclick="popupCode('%codeurl%');return false;"> -ENDIF:codeurl -IF:sourcecode - <a href="#%aref%" class="method-signature"> -ENDIF:sourcecode -IF:callseq - <span class="method-name">%callseq%</span> -ENDIF:callseq -IFNOT:callseq - <span class="method-name">%name%</span><span class="method-args">%params%</span> -ENDIF:callseq -IF:codeurl +<% if methods["codeurl"] then %> + <a href="<%= methods["codeurl"] %>" target="Code" class="method-signature" + onclick="popupCode('<%= methods["codeurl"] %>');return false;"> +<% end %> +<% if methods["sourcecode"] then %> + <a href="#<%= methods["aref"] %>" class="method-signature"> +<% end %> +<% if methods["callseq"] then %> + <span class="method-name"><%= methods["callseq"] %></span> +<% end %> +<% unless methods["callseq"] then %> + <span class="method-name"><%= methods["name"] %></span><span class="method-args"><%= methods["params"] %></span> +<% end %> +<% if methods["codeurl"] then %> </a> -ENDIF:codeurl -IF:sourcecode +<% end %> +<% if methods["sourcecode"] then %> </a> -ENDIF:sourcecode +<% end %> </div> - + <div class="method-description"> -IF:m_desc - %m_desc% -ENDIF:m_desc -IF:sourcecode +<% if methods["m_desc"] then %> + <%= methods["m_desc"] %> +<% end %> +<% if methods["sourcecode"] then %> <p><a class="source-toggle" href="#" - onclick="toggleCode('%aref%-source');return false;">[Source]</a></p> - <div class="method-source-code" id="%aref%-source"> + onclick="toggleCode('<%= methods["aref"] %>-source');return false;">[Source]</a></p> + <div class="method-source-code" id="<%= methods["aref"] %>-source"> <pre> -%sourcecode% +<%= methods["sourcecode"] %> </pre> </div> -ENDIF:sourcecode +<% end %> </div> </div> -END:methods -ENDIF:methods -END:method_list +<% end # method_list["methods"] %> +<% end %> +<% end # sections["method_list"] %> </div> -ENDIF:method_list -END:sections -} +<% end %> +<% end # values["sections"] %> +EOF ##################################################################### @@ -610,7 +610,7 @@ END:sections BODY = HEADER + %{ -!INCLUDE! <!-- banner header --> +<%= template_include %> <!-- banner header --> <div id="bodyContent"> @@ -626,18 +626,18 @@ BODY = HEADER + %{ ### S O U R C E C O D E T E M P L A T E ##################################################################### -SRC_PAGE = XHTML_PREAMBLE + %{ +SRC_PAGE = XHTML_PREAMBLE + <<-EOF <html> <head> - <title>%title%</title> - <meta http-equiv="Content-Type" content="text/html; charset=%charset%" /> - <link rel="stylesheet" href="%style_url%" type="text/css" media="screen" /> + <title><%= values["title"] %></title> + <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>" /> + <link rel="stylesheet" href="<%= values["style_url"] %>" type="text/css" media="screen" /> </head> <body class="standalone-code"> - <pre>%code%</pre> + <pre><%= values["code"] %></pre> </body> </html> -} +EOF ##################################################################### @@ -645,29 +645,29 @@ SRC_PAGE = XHTML_PREAMBLE + %{ ##################################################################### FR_INDEX_BODY = %{ -!INCLUDE! +<%= template_include %> } FILE_INDEX = XHTML_PREAMBLE + %{ <!-- - %list_title% + <%= values["list_title"] %> --> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> - <title>%list_title%</title> - <meta http-equiv="Content-Type" content="text/html; charset=%charset%" /> - <link rel="stylesheet" href="%style_url%" type="text/css" /> + <title><%= values["list_title"] %></title> + <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>" /> + <link rel="stylesheet" href="<%= values["style_url"] %>" type="text/css" /> <base target="docwin" /> </head> <body> <div id="index"> - <h1 class="section-bar">%list_title%</h1> + <h1 class="section-bar"><%= values["list_title"] %></h1> <div id="index-entries"> -START:entries - <a href="%href%">%name%</a><br /> -END:entries +<% values["entries"].each do |entries| %> + <a href="<%= entries["href"] %>"><%= entries["name"] %></a><br /> +<% end # values["entries"] %> </div> </div> </body> @@ -677,20 +677,20 @@ END:entries CLASS_INDEX = FILE_INDEX METHOD_INDEX = FILE_INDEX -INDEX = %{<?xml version="1.0" encoding="%charset%"?> -<!DOCTYPE html +INDEX = %{<?xml version="1.0" encoding="<%= values["charset"] %>"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <!-- - %title% + <%= values["title"] %> --> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> - <title>%title%</title> - <meta http-equiv="Content-Type" content="text/html; charset=%charset%" /> + <title><%= values["title"] %></title> + <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>" /> </head> <frameset rows="20%, 80%"> <frameset cols="25%,35%,45%"> @@ -698,7 +698,7 @@ INDEX = %{<?xml version="1.0" encoding="%charset%"?> <frame src="fr_class_index.html" name="Classes" /> <frame src="fr_method_index.html" name="Methods" /> </frameset> - <frame src="%initial_page%" name="docwin" /> + <frame src="<%= values["initial_page"] %>" name="docwin" /> </frameset> </html> } diff --git a/lib/rdoc/generators/template/html/kilmer.rb b/lib/rdoc/generators/template/html/kilmer.rb index 55071fc02..64687ff3c 100644 --- a/lib/rdoc/generators/template/html/kilmer.rb +++ b/lib/rdoc/generators/template/html/kilmer.rb @@ -5,7 +5,7 @@ module Page FONTS = "Verdana, Arial, Helvetica, sans-serif" STYLE = %{ -body,td,p { font-family: %fonts%; +body,td,p { font-family: <%= values["fonts"] %>; color: #000040; } @@ -18,20 +18,20 @@ body,td,p { font-family: %fonts%; .big-title-font { color: black; font-weight: bold; - font-family: %fonts%; + font-family: <%= values["fonts"] %>; font-size: large; height: 60px; padding: 10px 3px 10px 3px; } .small-title-font { color: black; - font-family: %fonts%; + font-family: <%= values["fonts"] %>; font-size:10; } .aqua { color: black } .method-name, .attr-name { - font-family: font-family: %fonts%; + font-family: font-family: <%= values["fonts"] %>; font-weight: bold; font-size: small; margin-left: 20px; @@ -92,9 +92,9 @@ body,td,p { font-family: %fonts%; BODY = %{ <html><head> - <title>%title%</title> - <meta http-equiv="Content-Type" content="text/html; charset=%charset%"> - <link rel="stylesheet" href="%style_url%" type="text/css" media="screen" /> + <title><%= values["title"] %></title> + <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> + <link rel="stylesheet" href="<%= values["style_url"] %>" type="text/css" media="screen" /> <script type="text/javascript" language="JavaScript"> <!-- function popCode(url) { @@ -105,82 +105,82 @@ BODY = %{ </head> <body bgcolor="white"> -!INCLUDE! <!-- banner header --> +<%= template_include %> <!-- banner header --> -IF:diagram +<% if values["diagram"] then %> <table width="100%"><tr><td align="center"> -%diagram% +<%= values["diagram"] %> </td></tr></table> -ENDIF:diagram +<% end %> -IF:description -<div class="description">%description%</div> -ENDIF:description +<% if values["description"] then %> +<div class="description"><%= values["description"] %></div> +<% end %> -IF:requires +<% if values["requires"] then %> <table cellpadding="5" width="100%"> <tr><td class="tablesubtitle">Required files</td></tr> </table><br /> <div class="name-list"> -START:requires -HREF:aref:name: -END:requires -ENDIF:requires +<% values["requires"].each do |requires| %> +<%= href requires["aref"], requires["name"] %> +<% end # values["requires"] %> +<% end %> </div> -IF:methods +<% if values["methods"] then %> <table cellpadding="5" width="100%"> <tr><td class="tablesubtitle">Methods</td></tr> </table><br /> <div class="name-list"> -START:methods -HREF:aref:name:, -END:methods +<% values["methods"].each do |methods| %> +<%= href methods["aref"], methods["name"] %>, +<% end # values["methods"] %> </div> -ENDIF:methods +<% end %> -START:sections +<% values["sections"].each do |sections| %> <div id="section"> -IF:sectitle - <h2 class="section-title"><a name="%secsequence%">%sectitle%</a></h2> -IF:seccomment +<% if sections["sectitle"] then %> + <h2 class="section-title"><a name="<%= sections["secsequence"] %>"><%= sections["sectitle"] %></a></h2> +<% if sections["seccomment"] then %> <div class="section-comment"> - %seccomment% - </div> -ENDIF:seccomment -ENDIF:sectitle + <%= sections["seccomment"] %> + </div> +<% end %> +<% end %> -IF:attributes +<% if sections["attributes"] then %> <table cellpadding="5" width="100%"> <tr><td class="tablesubtitle">Attributes</td></tr> </table><br /> <table cellspacing="5"> -START:attributes +<% sections["attributes"].each do |attributes| %> <tr valign="top"> -IF:rw - <td align="center" class="attr-rw"> [%rw%] </td> -ENDIF:rw -IFNOT:rw +<% if attributes["rw"] then %> + <td align="center" class="attr-rw"> [<%= attributes["rw"] %>] </td> +<% end %> +<% unless attributes["rw"] then %> <td></td> -ENDIF:rw - <td class="attr-name">%name%</td> - <td>%a_desc%</td> +<% end %> + <td class="attr-name"><%= attributes["name"] %></td> + <td><%= attributes["a_desc"] %></td> </tr> -END:attributes +<% end # sections["attributes"] %> </table> -ENDIF:attributes +<% end %> -IF:classlist +<% if sections["classlist"] then %> <table cellpadding="5" width="100%"> <tr><td class="tablesubtitle">Classes and Modules</td></tr> </table><br /> -%classlist%<br /> -ENDIF:classlist +<%= sections["classlist"] %><br /> +<% end %> - !INCLUDE! <!-- method descriptions --> + <%= template_include %> <!-- method descriptions --> -END:sections +<% end # values["sections"] %> </body> </html> @@ -192,19 +192,19 @@ FILE_PAGE = <<_FILE_PAGE_ <table width="100%"> <tr class="title-row"> <td><table width="100%"><tr> - <td class="big-title-font" colspan="2"><font size="-3"><b>File</b><br /></font>%short_name%</td> + <td class="big-title-font" colspan="2"><font size="-3"><b>File</b><br /></font><%= values["short_name"] %></td> <td align="right"><table cellspacing="0" cellpadding="2"> <tr> <td class="small-title-font">Path:</td> - <td class="small-title-font">%full_path% -IF:cvsurl - (<a href="%cvsurl%"><acronym title="Concurrent Versioning System">CVS</acronym></a>) -ENDIF:cvsurl + <td class="small-title-font"><%= values["full_path"] %> +<% if values["cvsurl"] then %> + (<a href="<%= values["cvsurl"] %>"><acronym title="Concurrent Versioning System">CVS</acronym></a>) +<% end %> </td> </tr> <tr> <td class="small-title-font">Modified:</td> - <td class="small-title-font">%dtm_modified%</td> + <td class="small-title-font"><%= values["dtm_modified"] %></td> </tr> </table> </td></tr></table></td> @@ -218,35 +218,35 @@ CLASS_PAGE = %{ <table width="100%" border="0" cellspacing="0"> <tr class="title-row"> <td class="big-title-font"> - <font size="-3"><b>%classmod%</b><br /></font>%full_name% + <font size="-3"><b><%= values["classmod"] %></b><br /></font><%= values["full_name"] %> </td> <td align="right"> <table cellspacing="0" cellpadding="2"> <tr valign="top"> <td class="small-title-font">In:</td> <td class="small-title-font"> -START:infiles -HREF:full_path_url:full_path: -IF:cvsurl - (<a href="%cvsurl%"><acronym title="Concurrent Versioning System">CVS</acronym></a>) -ENDIF:cvsurl -END:infiles +<% values["infiles"].each do |infiles| %> +<%= href infiles["full_path_url"], infiles["full_path"] %> +<% if infiles["cvsurl"] then %> + (<a href="<%= infiles["cvsurl"] %>"><acronym title="Concurrent Versioning System">CVS</acronym></a>) +<% end %> +<% end # values["infiles"] %> </td> </tr> -IF:parent +<% if values["parent"] then %> <tr> <td class="small-title-font">Parent:</td> <td class="small-title-font"> -IF:par_url - <a href="%par_url%" class="cyan"> -ENDIF:par_url -%parent% -IF:par_url +<% if values["par_url"] then %> + <a href="<%= values["par_url"] %>" class="cyan"> +<% end %> +<%= values["parent"] %> +<% if values["par_url"] then %> </a> -ENDIF:par_url +<% end %> </td> </tr> -ENDIF:parent +<% end %> </table> </td> </tr> @@ -256,58 +256,58 @@ ENDIF:parent ################################################################### METHOD_LIST = %{ -IF:includes +<% if values["includes"] then %> <div class="tablesubsubtitle">Included modules</div><br /> <div class="name-list"> -START:includes - <span class="method-name">HREF:aref:name:</span> -END:includes +<% values["includes"].each do |includes| %> + <span class="method-name"><%= href includes["aref"], includes["name"] %></span> +<% end # values["includes"] %> </div> -ENDIF:includes +<% end %> -IF:method_list -START:method_list -IF:methods +<% if values["method_list"] then %> +<% values["method_list"].each do |method_list| $stderr.puts({ :method_list => method_list }.inspect) %> +<% if values["methods"] then %> <table cellpadding=5 width="100%"> -<tr><td class="tablesubtitle">%type% %category% methods</td></tr> +<tr><td class="tablesubtitle"><%= values["type"] %> <%= values["category"] %> methods</td></tr> </table> -START:methods +<% values["methods"].each do |methods| $stderr.puts({ :methods => methods }.inspect) %> <table width="100%" cellspacing="0" cellpadding="5" border="0"> <tr><td class="methodtitle"> -<a name="%aref%"> -IF:callseq -<b>%callseq%</b> -ENDIF:callseq -IFNOT:callseq - <b>%name%</b>%params% -ENDIF:callseq -IF:codeurl -<a href="%codeurl%" target="source" class="srclink">src</a> -ENDIF:codeurl +<a name="<%= values["aref"] %>"> +<% if values["callseq"] then %> +<b><%= values["callseq"] %></b> +<% end %> +<% unless values["callseq"] then %> + <b><%= values["name"] %></b><%= values["params"] %> +<% end %> +<% if values["codeurl"] then %> +<a href="<%= values["codeurl"] %>" target="source" class="srclink">src</a> +<% end %> </a></td></tr> </table> -IF:m_desc +<% if values["m_desc"] then %> <div class="description"> -%m_desc% +<%= values["m_desc"] %> </div> -ENDIF:m_desc -IF:aka +<% end %> +<% if values["aka"] then %> <div class="aka"> This method is also aliased as -START:aka -<a href="%aref%">%name%</a> -END:aka +<% values["aka"].each do |aka| $stderr.puts({ :aka => aka }.inspect) %> +<a href="<%= values["aref"] %>"><%= values["name"] %></a> +<% end # values["aka"] %> </div> -ENDIF:aka -IF:sourcecode +<% end %> +<% if values["sourcecode"] then %> <pre class="source"> -%sourcecode% +<%= values["sourcecode"] %> </pre> -ENDIF:sourcecode -END:methods -ENDIF:methods -END:method_list -ENDIF:method_list +<% end %> +<% end # values["methods"] %> +<% end %> +<% end # values["method_list"] %> +<% end %> } =begin @@ -317,8 +317,8 @@ ENDIF:method_list SRC_PAGE = %{ <html> -<head><title>%title%</title> -<meta http-equiv="Content-Type" content="text/html; charset=%charset%"> +<head><title><%= values["title"] %></title> +<meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> <style type="text/css"> .ruby-comment { color: green; font-style: italic } .ruby-constant { color: #4433aa; font-weight: bold; } @@ -336,7 +336,7 @@ SRC_PAGE = %{ </style> </head> <body bgcolor="white"> -<pre>%code%</pre> +<pre><%= values["code"] %></pre> </body> </html> } @@ -344,13 +344,13 @@ SRC_PAGE = %{ ########################## Index ################################ FR_INDEX_BODY = %{ -!INCLUDE! +<%= template_include %> } FILE_INDEX = %{ <html> <head> -<meta http-equiv="Content-Type" content="text/html; charset=%charset%"> +<meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> <style> <!-- body { @@ -378,10 +378,10 @@ div.banner { <base target="docwin"> </head> <body> -<div class="banner">%list_title%</div> -START:entries -<a href="%href%">%name%</a><br /> -END:entries +<div class="banner"><%= values["list_title"] %></div> +<% values["entries"].each do |entries| %> +<a href="<%= entries["href"] %>"><%= entries["name"] %></a><br /> +<% end # values["entries"] %> </body></html> } @@ -391,8 +391,8 @@ METHOD_INDEX = FILE_INDEX INDEX = %{ <html> <head> - <title>%title%</title> - <meta http-equiv="Content-Type" content="text/html; charset=%charset%"> + <title><%= values["title"] %></title> + <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>"> </head> <frameset cols="20%,*"> @@ -401,15 +401,15 @@ INDEX = %{ <frame src="fr_class_index.html" name="Classes"> <frame src="fr_method_index.html" name="Methods"> </frameset> -IF:inline_source - <frame src="%initial_page%" name="docwin"> -ENDIF:inline_source -IFNOT:inline_source +<% if values["inline_source"] then %> + <frame src="<%= values["initial_page"] %>" name="docwin"> +<% end %> +<% unless values["inline_source"] then %> <frameset rows="80%,20%"> - <frame src="%initial_page%" name="docwin"> + <frame src="<%= values["initial_page"] %>" name="docwin"> <frame src="blank.html" name="source"> </frameset> -ENDIF:inline_source +<% end %> <noframes> <body bgcolor="white"> Click <a href="html/index.html">here</a> for a non-frames diff --git a/lib/rdoc/generators/template/html/old_html.rb b/lib/rdoc/generators/template/html/old_html.rb deleted file mode 100644 index ca66302a0..000000000 --- a/lib/rdoc/generators/template/html/old_html.rb +++ /dev/null @@ -1,728 +0,0 @@ -module RDoc - -# This is how you define the HTML that RDoc generates. Simply create -# a file in rdoc/generators/html_templates that creates the -# module RDoc::Page and populate it as described below. Then invoke -# rdoc using the --template <name of your file> option, and -# your template will be used. -# -# The constants defining pages use a simple templating system: -# -# * The templating system is passed a hash. Keys in the hash correspond -# to tags on this page. The tag %abc% is looked up in the hash, -# and is replaced by the corresponding hash value. -# -# * Some tags are optional. You can detect this using IF/ENDIF -# -# IF: title -# The value of title is %title% -# ENDIF: title -# -# * Some entries in the hash have values that are arrays, where each -# entry in the array is itself a hash. These are used to generate -# lists using the START: construct. For example, given a hash -# containing -# -# { 'people' => [ { 'name' => 'Fred', 'age' => '12' }, -# { 'name' => 'Mary', 'age' => '21' } ] -# -# You could generate a simple table using -# -# <table> -# START:people -# <tr><td>%name%<td>%age%</tr> -# END:people -# </table> -# -# These lists can be nested to an arbitrary depth -# -# * the construct HREF:url:name: generates <a href="%url%">%name%</a> -# if +url+ is defined in the hash, or %name% otherwise. -# -# -# Your file must contain the following constants -# -# [*FONTS*] a list of fonts to be used -# [*STYLE*] a CSS section (without the <style> or comments). This is -# used to generate a style.css file -# -# [*BODY*] -# The main body of all non-index RDoc pages. BODY will contain -# two !INCLUDE!s. The first is used to include a document-type -# specific header (FILE_PAGE or CLASS_PAGE). The second include -# is for the method list (METHOD_LIST). THe body is passed: -# -# %title%:: -# the page's title -# -# %style_url%:: -# the url of a style sheet for this page -# -# %diagram%:: -# the optional URL of a diagram for this page -# -# %description%:: -# a (potentially multi-paragraph) string containing the -# description for th file/class/module. -# -# %requires%:: -# an optional list of %aref%/%name% pairs, one for each module -# required by this file. -# -# %methods%:: -# an optional list of %aref%/%name%, one for each method -# documented on this page. This is intended to be an index. -# -# %attributes%:: -# An optional list. For each attribute it contains: -# %name%:: the attribute name -# %rw%:: r/o, w/o, or r/w -# %a_desc%:: description of the attribute -# -# %classlist%:: -# An optional string containing an already-formatted list of -# classes and modules documented in this file -# -# For FILE_PAGE entries, the body will be passed -# -# %short_name%:: -# The name of the file -# -# %full_path%:: -# The full path to the file -# -# %dtm_modified%:: -# The date/time the file was last changed -# -# For class and module pages, the body will be passed -# -# %classmod%:: -# The name of the class or module -# -# %files%:: -# A list. For each file this class is defined in, it contains: -# %full_path_url%:: an (optional) URL of the RDoc page -# for this file -# %full_path%:: the name of the file -# -# %par_url%:: -# The (optional) URL of the RDoc page documenting this class's -# parent class -# -# %parent%:: -# The name of this class's parent. -# -# For both files and classes, the body is passed the following information -# on includes and methods: -# -# %includes%:: -# Optional list of included modules. For each, it receives -# %aref%:: optional URL to RDoc page for the module -# %name%:: the name of the module -# -# %method_list%:: -# Optional list of methods of a particular class and category. -# -# Each method list entry contains: -# -# %type%:: public/private/protected -# %category%:: instance/class -# %methods%:: a list of method descriptions -# -# Each method description contains: -# -# %aref%:: a target aref, used when referencing this method -# description. You should code this as <a name="%aref%"> -# %codeurl%:: the optional URL to the page containing this method's -# source code. -# %name%:: the method's name -# %params%:: the method's parameters -# %callseq%:: a full calling sequence -# %m_desc%:: the (potentially multi-paragraph) description of -# this method. -# -# [*CLASS_PAGE*] -# Header for pages documenting classes and modules. See -# BODY above for the available parameters. -# -# [*FILE_PAGE*] -# Header for pages documenting files. See -# BODY above for the available parameters. -# -# [*METHOD_LIST*] -# Controls the display of the listing of methods. See BODY for -# parameters. -# -# [*INDEX*] -# The top-level index page. For a browser-like environment -# define a frame set that includes the file, class, and -# method indices. Passed -# %title%:: title of page -# %initial_page% :: url of initial page to display -# -# [*CLASS_INDEX*] -# Individual files for the three indexes. Passed: -# %index_url%:: URL of main index page -# %entries%:: List of -# %name%:: name of an index entry -# %href%:: url of corresponding page -# [*METHOD_INDEX*] -# Same as CLASS_INDEX for methods -# -# [*FILE_INDEX*] -# Same as CLASS_INDEX for methods -# -# [*FR_INDEX_BODY*] -# A wrapper around CLASS_INDEX, METHOD_INDEX, and FILE_INDEX. -# If those index strings contain the complete HTML for the -# output, then FR_INDEX_BODY can simply be !INCLUDE! -# -# [*SRC_PAGE*] -# Page used to display source code. Passed %title% and %code%, -# the latter being a multi-line string of code. - -module Page - -FONTS = "Verdana, Arial, Helvetica, sans-serif" - -STYLE = %{ -body,td,p { font-family: %fonts%; - color: #000040; -} - -.attr-rw { font-size: x-small; color: #444488 } - -.title-row { background: #0000aa; - color: #eeeeff; -} - -.big-title-font { color: white; - font-family: %fonts%; - font-size: large; - height: 50px} - -.small-title-font { color: aqua; - font-family: %fonts%; - font-size: xx-small; } - -.aqua { color: aqua } - -.method-name, attr-name { - font-family: monospace; font-weight: bold; -} - -.tablesubtitle, .tablesubsubtitle { - width: 100%; - margin-top: 1ex; - margin-bottom: .5ex; - padding: 5px 0px 5px 20px; - font-size: large; - color: aqua; - background: #3333cc; -} - -.name-list { - font-family: monospace; - margin-left: 40px; - margin-bottom: 2ex; - line-height: 140%; -} - -.description { - margin-left: 40px; - margin-top: -2ex; - margin-bottom: 2ex; -} - -.description p { - line-height: 140%; -} - -.aka { - margin-left: 40px; - margin-bottom: 2ex; - line-height: 100%; - font-size: small; - color: #808080; -} - -.methodtitle { - font-size: medium; - text-decoration: none; - color: #0000AA; - background: white; -} - -.paramsig { - font-size: small; -} - -.srcbut { float: right } - -pre { font-size: 1.2em; } -tt { font-size: 1.2em; } - -pre.source { - border-style: groove; - background-color: #ddddff; - margin-left: 40px; - padding: 1em 0em 1em 2em; -} - -.classlist { - margin-left: 40px; - margin-bottom: 2ex; - line-height: 140%; -} - -li { - display: list-item; - margin-top: .6em; -} - -.ruby-comment { color: green; font-style: italic } -.ruby-constant { color: #4433aa; font-weight: bold; } -.ruby-identifier { color: #222222; } -.ruby-ivar { color: #2233dd; } -.ruby-keyword { color: #3333FF; font-weight: bold } -.ruby-node { color: #777777; } -.ruby-operator { color: #111111; } -.ruby-regexp { color: #662222; } -.ruby-value { color: #662222; font-style: italic } - -} - - -############################################################################ - - -HEADER = %{ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" -"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <title>%title%</title> - <meta http-equiv="Content-Type" content="text/html; charset=%charset%" /> - <link rel=StyleSheet href="%style_url%" type="text/css" media="screen" /> - <script type="text/javascript" language="JavaScript"> - <!-- - function popCode(url) { - window.open(url, "Code", - "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") - } - //--> - </script> -</head> -} - - -################################################################### - -METHOD_LIST = %{ -IF:includes -<table summary="Included modules" cellpadding="5" width="100%"> -<tr><td class="tablesubtitle">Included modules</td></tr> -</table> -<div class="name-list"> -START:includes - <span class="method-name">HREF:aref:name:</span> -END:includes -</div> -ENDIF:includes - -IF:method_list -START:method_list -IF:methods -<table summary="Method list" cellpadding="5" width="100%"> -<tr><td class="tablesubtitle">%type% %category% methods</td></tr> -</table> -START:methods -<table summary="method" width="100%" cellspacing="0" cellpadding="5" border="0"> -<tr><td class="methodtitle"> -<a name="%aref%"></a> -IF:codeurl -<a href="%codeurl%" target="Code" class="methodtitle" - onClick="popCode('%codeurl%');return false;"> -ENDIF:codeurl -IF:callseq -<b>%callseq%</b> -ENDIF:callseq -IFNOT:callseq -<b>%name%</b>%params% -ENDIF:callseq -IF:codeurl -</a> -ENDIF:codeurl -</td></tr> -</table> -IF:m_desc -<div class="description"> -%m_desc% -</div> -ENDIF:m_desc -IF:aka -<div class="aka"> -This method is also aliased as -START:aka -<a href="%aref%">%name%</a> -END:aka -</div> -ENDIF:aka -IF:sourcecode -<pre class="source"> -%sourcecode% -</pre> -ENDIF:sourcecode -END:methods -ENDIF:methods -END:method_list -ENDIF:method_list -} - -################################################################### - -CONTEXT_CONTENT = %{ -IF:diagram -<table summary="Diagram of classes and modules" width="100%"> -<tr><td align="center"> -%diagram% -</td></tr></table> -ENDIF:diagram - - -IF:description -<div class="description">%description%</div> -ENDIF:description - -IF:requires -<table summary="Requires" cellpadding="5" width="100%"> -<tr><td class="tablesubtitle">Required files</td></tr> -</table> -<div class="name-list"> -START:requires -HREF:aref:name: -END:requires -</div> -ENDIF:requires - -IF:methods -<table summary="Methods" cellpadding="5" width="100%"> -<tr><td class="tablesubtitle">Methods</td></tr> -</table> -<div class="name-list"> -START:methods -HREF:aref:name: -END:methods -</div> -ENDIF:methods - -IF:constants -<table summary="Constants" cellpadding="5" width="100%"> -<tr><td class="tablesubtitle">Constants</td></tr> -</table> -<table cellpadding="5"> -START:constants -<tr valign="top"><td>%name%</td><td>=</td><td>%value%</td></tr> -IF:desc -<tr><td></td><td></td><td>%desc%</td></tr> -ENDIF:desc -END:constants -</table> -ENDIF:constants - -IF:aliases -<table summary="Aliases" cellpadding="5" width="100%"> -<tr><td class="tablesubtitle">External Aliases</td></tr> -</table> -<div class="name-list"> -START:aliases -%old_name% -> %new_name%<br /> -END:aliases -</div> -ENDIF:aliases - -IF:attributes -<table summary="Attributes" cellpadding="5" width="100%"> -<tr><td class="tablesubtitle">Attributes</td></tr> -</table> -<table summary="Attribute details" cellspacing="5"> -START:attributes - <tr valign="top"> - <td class="attr-name">%name%</td> -IF:rw - <td align="center" class="attr-rw"> [%rw%] </td> -ENDIF:rw -IFNOT:rw - <td></td> -ENDIF:rw - <td>%a_desc%</td> - </tr> -END:attributes -</table> -ENDIF:attributes - -IF:classlist -<table summary="List of classes" cellpadding="5" width="100%"> -<tr><td class="tablesubtitle">Classes and Modules</td></tr> -</table> -<div class="classlist"> -%classlist% -</div> -ENDIF:classlist -} - -############################################################################### - -BODY = HEADER + %{ -<body bgcolor="white"> -!INCLUDE! <!-- banner header --> -} + -CONTEXT_CONTENT + METHOD_LIST + -%{ -</body> -</html> -} - - -############################################################################### - -FILE_PAGE = <<_FILE_PAGE_ -<table summary="Information on file" width="100%"> - <tr class="title-row"> - <td><table summary="layout" width="100%"><tr> - <td class="big-title-font" colspan="2">%short_name%</td> - <td align="right"><table summary="layout" cellspacing="0" cellpadding="2"> - <tr> - <td class="small-title-font">Path:</td> - <td class="small-title-font">%full_path% -IF:cvsurl - (<a href="%cvsurl%"><acronym title="Concurrent Versioning System">CVS</acronym></a>) -ENDIF:cvsurl - </td> - </tr> - <tr> - <td class="small-title-font">Modified:</td> - <td class="small-title-font">%dtm_modified%</td> - </tr> - </table> - </td></tr></table></td> - </tr> -</table> -_FILE_PAGE_ - -################################################################### - -CLASS_PAGE = %{ -<table summary="Information on class" width="100%" border="0" cellspacing="0"> - <tr class="title-row"> - <td class="big-title-font"> - <sup><font color="aqua">%classmod%</font></sup> %full_name% - </td> - <td align="right"> - <table summary="layout" cellspacing="0" cellpadding="2"> - <tr valign="top"> - <td class="small-title-font">In:</td> - <td class="small-title-font"> -START:infiles -IF:full_path_url - <a href="%full_path_url%" class="aqua"> -ENDIF:full_path_url -%full_path% -IF:full_path_url - </a> -ENDIF:full_path_url -IF:cvsurl - (<a href="%cvsurl%"><acronym title="Concurrent Versioning System">CVS</acronym></a>) -ENDIF:cvsurl -<br /> -END:infiles - </td> - </tr> -IF:parent - <tr> - <td class="small-title-font">Parent:</td> - <td class="small-title-font"> -IF:par_url - <a href="%par_url%" class="aqua"> -ENDIF:par_url -%parent% -IF:par_url - </a> -ENDIF:par_url - </td> - </tr> -ENDIF:parent - </table> - </td> - </tr> -</table> -} - -=begin -=end - -########################## Source code ########################## - -SRC_PAGE = %{ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=%charset%"> -<title>%title%</title> -<link rel="stylesheet" href="%style_url%" type="text/css" media="screen" /> -</head> -<body bgcolor="white"> -<pre>%code%</pre> -</body> -</html> -} - -########################## Index ################################ - -FR_INDEX_BODY = %{ -!INCLUDE! -} - -FILE_INDEX = %{ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=%charset%"> -<title>%list_title%</title> -<style type="text/css"> -<!-- - body { -background-color: #ddddff; - font-family: #{FONTS}; - font-size: 11px; - font-style: normal; - line-height: 14px; - color: #000040; - } -div.banner { - background: #0000aa; - color: white; - padding: 1; - margin: 0; - font-size: 90%; - font-weight: bold; - line-height: 1.1; - text-align: center; - width: 100%; -} - -A.xx { color: white; font-weight: bold; } ---> -</style> -<base target="docwin"> -</head> -<body> -<div class="banner"><a href="%index_url%" class="xx">%list_title%</a></div> -START:entries -<a href="%href%">%name%</a><br /> -END:entries -</body></html> -} - -CLASS_INDEX = FILE_INDEX -METHOD_INDEX = FILE_INDEX - -INDEX = %{ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"> -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=%charset%"> -<title>%title%</title></head> - -<frameset rows="20%, 80%"> - <frameset cols="25%,35%,45%"> - <frame src="fr_file_index.html" title="Files" name="Files"> - <frame src="fr_class_index.html" name="Classes"> - <frame src="fr_method_index.html" name="Methods"> - </frameset> - <frame src="%initial_page%" name="docwin"> - <noframes> - <body bgcolor="white"> - Sorry, RDoc currently only generates HTML using frames. - </body> - </noframes> -</frameset> - -</html> -} - -###################################################################### -# -# The following is used for the -1 option -# - -CONTENTS_XML = %{ -IF:description -%description% -ENDIF:description - -IF:requires -<h4>Requires:</h4> -<ul> -START:requires -IF:aref -<li><a href="%aref%">%name%</a></li> -ENDIF:aref -IFNOT:aref -<li>%name%</li> -ENDIF:aref -END:requires -</ul> -ENDIF:requires - -IF:attributes -<h4>Attributes</h4> -<table> -START:attributes -<tr><td>%name%</td><td>%rw%</td><td>%a_desc%</td></tr> -END:attributes -</table> -ENDIF:attributes - -IF:includes -<h4>Includes</h4> -<ul> -START:includes -IF:aref -<li><a href="%aref%">%name%</a></li> -ENDIF:aref -IFNOT:aref -<li>%name%</li> -ENDIF:aref -END:includes -</ul> -ENDIF:includes - -IF:method_list -<h3>Methods</h3> -START:method_list -IF:methods -START:methods -<h4>%type% %category% method: <a name="%aref%">%name%%params%</a></h4> - -IF:m_desc -%m_desc% -ENDIF:m_desc - -IF:sourcecode -<blockquote><pre> -%sourcecode% -</pre></blockquote> -ENDIF:sourcecode -END:methods -ENDIF:methods -END:method_list -ENDIF:method_list -} - - -end -end - -require 'rdoc/generators/template/html/one_page_html' diff --git a/lib/rdoc/generators/template/html/one_page_html.rb b/lib/rdoc/generators/template/html/one_page_html.rb index 19441f472..170bbf23c 100644 --- a/lib/rdoc/generators/template/html/one_page_html.rb +++ b/lib/rdoc/generators/template/html/one_page_html.rb @@ -1,78 +1,77 @@ -module RDoc -module Page -###################################################################### -# -# The following is used for the -1 option -# +module RDoc::Page CONTENTS_XML = %{ -IF:description -%description% -ENDIF:description +<% if defined? classes and classes["description"] then %> +<%= classes["description"] %> +<% end %> -IF:requires +<% if defined? files and files["requires"] then %> <h4>Requires:</h4> <ul> -START:requires -IF:aref -<li><a href="%aref%">%name%</a></li> -ENDIF:aref -IFNOT:aref -<li>%name%</li> -ENDIF:aref -END:requires +<% files["requires"].each do |requires| %> +<% if requires["aref"] then %> +<li><a href="<%= requires["aref"] %>"><%= requires["name"] %></a></li> +<% end %> +<% unless requires["aref"] then %> +<li><%= requires["name"] %></li> +<% end %> +<% end # files["requires"] %> </ul> -ENDIF:requires +<% end %> -IF:attributes -<h4>Attributes</h4> -<table> -START:attributes -<tr><td>%name%</td><td>%rw%</td><td>%a_desc%</td></tr> -END:attributes -</table> -ENDIF:attributes - -IF:includes +<% if defined? classes and classes["includes"] then %> <h4>Includes</h4> <ul> -START:includes -IF:aref -<li><a href="%aref%">%name%</a></li> -ENDIF:aref -IFNOT:aref -<li>%name%</li> -ENDIF:aref -END:includes +<% classes["includes"].each do |includes| %> +<% if includes["aref"] then %> +<li><a href="<%= includes["aref"] %>"><%= includes["name"] %></a></li> +<% end %> +<% unless includes["aref"] then %> +<li><%= includes["name"] %></li> +<% end %> +<% end # classes["includes"] %> </ul> -ENDIF:includes +<% end %> + +<% if defined? classes and classes["sections"] then %> +<% classes["sections"].each do |sections| %> +<% if sections["attributes"] then %> +<h4>Attributes</h4> +<table> +<% sections["attributes"].each do |attributes| %> +<tr><td><%= attributes["name"] %></td><td><%= attributes["rw"] %></td><td><%= attributes["a_desc"] %></td></tr> +<% end # sections["attributes"] %> +</table> +<% end %> -IF:method_list +<% if sections["method_list"] then %> <h3>Methods</h3> -START:method_list -IF:methods -START:methods -<h4>%type% %category% method: -IF:callseq -<a name="%aref%">%callseq%</a> -ENDIF:callseq -IFNOT:callseq -<a name="%aref%">%name%%params%</a></h4> -ENDIF:callseq +<% sections["method_list"].each do |method_list| %> +<% if method_list["methods"] then %> +<% method_list["methods"].each do |methods| %> +<h4><%= methods["type"] %> <%= methods["category"] %> method: +<% if methods["callseq"] then %> +<a name="<%= methods["aref"] %>"><%= methods["callseq"] %></a> +<% end %> +<% unless methods["callseq"] then %> +<a name="<%= methods["aref"] %>"><%= methods["name"] %><%= methods["params"] %></a></h4> +<% end %> -IF:m_desc -%m_desc% -ENDIF:m_desc +<% if methods["m_desc"] then %> +<%= methods["m_desc"] %> +<% end %> -IF:sourcecode +<% if methods["sourcecode"] then %> <blockquote><pre> -%sourcecode% +<%= methods["sourcecode"] %> </pre></blockquote> -ENDIF:sourcecode -END:methods -ENDIF:methods -END:method_list -ENDIF:method_list +<% end %> +<% end # method_list["methods"] %> +<% end %> +<% end # sections["method_list"] %> +<% end %> +<% end # classes["sections"] %> +<% end %> } ######################################################################## @@ -81,42 +80,42 @@ ONE_PAGE = %{ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> - <title>%title%</title> - <meta http-equiv="Content-Type" content="text/html; charset=%charset%" /> + <title><%= values["title"] %></title> + <meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>" /> </head> <body> -START:files -<h2>File: %short_name%</h2> +<% values["files"].each do |files| %> +<h2>File: <%= files["short_name"] %></h2> <table> - <tr><td>Path:</td><td>%full_path%</td></tr> - <tr><td>Modified:</td><td>%dtm_modified%</td></tr> + <tr><td>Path:</td><td><%= files["full_path"] %></td></tr> + <tr><td>Modified:</td><td><%= files["dtm_modified"] %></td></tr> </table> } + CONTENTS_XML + %{ -END:files +<% end # values["files"] %> -IF:classes +<% if values["classes"] then %> <h2>Classes</h2> -START:classes -IF:parent -<h3>%classmod% %full_name% < HREF:par_url:parent:</h3> -ENDIF:parent -IFNOT:parent -<h3>%classmod% %full_name%</h3> -ENDIF:parent +<% values["classes"].each do |classes| %> +<% if classes["parent"] then %> +<h3><%= classes["classmod"] %> <%= classes["full_name"] %> < <%= href classes["par_url"], classes["parent"] %></h3> +<% end %> +<% unless classes["parent"] then %> +<h3><%= classes["classmod"] %> <%= classes["full_name"] %></h3> +<% end %> -IF:infiles +<% if classes["infiles"] then %> (in files -START:infiles -HREF:full_path_url:full_path: -END:infiles +<% classes["infiles"].each do |infiles| %> +<%= href infiles["full_path_url"], infiles["full_path"] %> +<% end # classes["infiles"] %> ) -ENDIF:infiles +<% end %> } + CONTENTS_XML + %{ -END:classes -ENDIF:classes +<% end # values["classes"] %> +<% end %> </body> </html> } end -end + diff --git a/lib/rdoc/generators/template/xml/rdf.rb b/lib/rdoc/generators/template/xml/rdf.rb index 1545d81a2..fbeb599ce 100644 --- a/lib/rdoc/generators/template/xml/rdf.rb +++ b/lib/rdoc/generators/template/xml/rdf.rb @@ -1,67 +1,68 @@ -module RDoc -module Page - - +module RDoc::Page CONTENTS_RDF = %{ -IF:description +<% if defined? classes and classes["description"] then %> <description rd:parseType="Literal"> -%description% +<%= classes["description"] %> </description> -ENDIF:description +<% end %> + +<% if defined? files and files["requires"] then %> +<% files["requires"].each do |requires| %> + <rd:required-file rd:name="<%= requires["name"] %>" /> +<% end # files["requires"] %> +<% end %> -IF:requires -START:requires - <rd:required-file rd:name="%name%" /> -END:requires -ENDIF:requires +<% if defined? classes and classes["includes"] then %> + <IncludedModuleList> +<% classes["includes"].each do |includes| %> + <included-module rd:name="<%= includes["name"] %>" /> +<% end # includes["includes"] %> + </IncludedModuleList> +<% end %> -IF:attributes -START:attributes +<% if defined? classes and classes["sections"] then %> +<% classes["sections"].each do |sections| %> +<% if sections["attributes"] then %> +<% sections["attributes"].each do |attributes| %> <contents> - <Attribute rd:name="%name%"> -IF:rw - <attribute-rw>%rw%</attribute-rw> -ENDIF:rw - <description rdf:parseType="Literal">%a_desc%</description> + <Attribute rd:name="<%= attributes["name"] %>"> +<% if attributes["rw"] then %> + <attribute-rw><%= attributes["rw"] %></attribute-rw> +<% end %> + <description rdf:parseType="Literal"><%= attributes["a_desc"] %></description> </Attribute> </contents> -END:attributes -ENDIF:attributes +<% end # sections["attributes"] %> +<% end %> -IF:includes - <IncludedModuleList> -START:includes - <included-module rd:name="%name%" /> -END:includes - </IncludedModuleList> -ENDIF:includes - -IF:method_list -START:method_list -IF:methods -START:methods +<% if sections["method_list"] then %> +<% sections["method_list"].each do |method_list| %> +<% if method_list["methods"] then %> +<% method_list["methods"].each do |methods| %> <contents> - <Method rd:name="%name%" rd:visibility="%type%" - rd:category="%category%" rd:id="%aref%"> - <parameters>%params%</parameters> -IF:m_desc + <Method rd:name="<%= methods["name"] %>" rd:visibility="<%= methods["type"] %>" + rd:category="<%= methods["category"] %>" rd:id="<%= methods["aref"] %>"> + <parameters><%= methods["params"] %></parameters> +<% if methods["m_desc"] then %> <description rdf:parseType="Literal"> -%m_desc% +<%= methods["m_desc"] %> </description> -ENDIF:m_desc -IF:sourcecode +<% end %> +<% if methods["sourcecode"] then %> <source-code-listing rdf:parseType="Literal"> -%sourcecode% +<%= methods["sourcecode"] %> </source-code-listing> -ENDIF:sourcecode +<% end %> </Method> </contents> -END:methods -ENDIF:methods -END:method_list -ENDIF:method_list +<% end # method_list["methods"] %> +<% end %> +<% end # sections["method_list"] %> +<% end %> <!-- end method list --> +<% end # classes["sections"] %> +<% end %> } ######################################################################## @@ -72,41 +73,39 @@ ONE_PAGE = %{<?xml version="1.0" encoding="utf-8"?> xmlns:rd="http://pragprog.com/rdoc/rdoc.rdf#"> <!-- RDoc --> -START:files - <rd:File rd:name="%short_name%" rd:id="%href%"> - <path>%full_path%</path> - <dtm-modified>%dtm_modified%</dtm-modified> +<% values["files"].each do |files| %> + <rd:File rd:name="<%= files["short_name"] %>" rd:id="<%= files["href"] %>"> + <path><%= files["full_path"] %></path> + <dtm-modified><%= files["dtm_modified"] %></dtm-modified> } + CONTENTS_RDF + %{ </rd:File> -END:files -START:classes - <%classmod% rd:name="%full_name%" rd:id="%full_name%"> +<% end # values["files"] %> +<% values["classes"].each do |classes| %> + <<%= values["classmod"] %> rd:name="<%= classes["full_name"] %>" rd:id="<%= classes["full_name"] %>"> <classmod-info> -IF:infiles +<% if classes["infiles"] then %> <InFiles> -START:infiles +<% classes["infiles"].each do |infiles| %> <infile> - <File rd:name="%full_path%" -IF:full_path_url - rdf:about="%full_path_url%" -ENDIF:full_path_url + <File rd:name="<%= infiles["full_path"] %>" +<% if infiles["full_path_url"] then %> + rdf:about="<%= infiles["full_path_url"] %>" +<% end %> /> </infile> -END:infiles +<% end # classes["infiles"] %> </InFiles> -ENDIF:infiles -IF:parent - <superclass>HREF:par_url:parent:</superclass> -ENDIF:parent +<% end %> +<% if classes["parent"] then %> + <superclass><%= href classes["par_url"], classes["parent"] %></superclass> +<% end %> </classmod-info> } + CONTENTS_RDF + %{ - </%classmod%> -END:classes + </<%= classes["classmod"] %>> +<% end # values["classes"] %> <!-- /RDoc --> </rdf:RDF> } - -end end diff --git a/lib/rdoc/generators/template/xml/xml.rb b/lib/rdoc/generators/template/xml/xml.rb index 4a0c8c9ac..ab6355a1c 100644 --- a/lib/rdoc/generators/template/xml/xml.rb +++ b/lib/rdoc/generators/template/xml/xml.rb @@ -1,73 +1,74 @@ -module RDoc -module Page - - +module RDoc::Page CONTENTS_XML = %{ -IF:description +<% if defined? classes and classes["description"] then %> <description> -%description% +<%= classes["description"] %> </description> -ENDIF:description +<% end %> <contents> -IF:requires +<% if defined? files and files["requires"] then %> <required-file-list> -START:requires - <required-file name="%name%" -IF:aref - href="%aref%" -ENDIF:aref +<% files["requires"].each do |requires| %> + <required-file name="<%= requires["name"] %>" +<% if requires["aref"] then %> + href="<%= requires["aref"] %>" +<% end %> /> -END:requires +<% end # files["requires"] %> </required-file-list> -ENDIF:requires -IF:attributes +<% end %> +<% if defined? classes and classes["sections"] then %> +<% classes["sections"].each do |sections| %> +<% if sections["attributes"] then %> <attribute-list> -START:attributes - <attribute name="%name%"> -IF:rw - <attribute-rw>%rw%</attribute-rw> -ENDIF:rw - <description>%a_desc%</description> +<% sections["attributes"].each do |attributes| %> + <attribute name="<%= attributes["name"] %>"> +<% if attributes["rw"] then %> + <attribute-rw><%= attributes["rw"] %></attribute-rw> +<% end %> + <description><%= attributes["a_desc"] %></description> </attribute> -END:attributes +<% end # sections["attributes"] %> </attribute-list> -ENDIF:attributes -IF:includes - <included-module-list> -START:includes - <included-module name="%name%" -IF:aref - href="%aref%" -ENDIF:aref - /> -END:includes - </included-module-list> -ENDIF:includes -IF:method_list +<% end %> +<% if sections["method_list"] then %> <method-list> -START:method_list -IF:methods -START:methods - <method name="%name%" type="%type%" category="%category%" id="%aref%"> - <parameters>%params%</parameters> -IF:m_desc +<% sections["method_list"].each do |method_list| %> +<% if method_list["methods"] then %> +<% method_list["methods"].each do |methods| %> + <method name="<%= methods["name"] %>" type="<%= methods["type"] %>" category="<%= methods["category"] %>" id="<%= methods["aref"] %>"> + <parameters><%= methods["params"] %></parameters> +<% if methods["m_desc"] then %> <description> -%m_desc% +<%= methods["m_desc"] %> </description> -ENDIF:m_desc -IF:sourcecode +<% end %> +<% if methods["sourcecode"] then %> <source-code-listing> -%sourcecode% +<%= methods["sourcecode"] %> </source-code-listing> -ENDIF:sourcecode +<% end %> </method> -END:methods -ENDIF:methods -END:method_list +<% end # method_list["methods"] %> +<% end %> +<% end # sections["method_list"] %> </method-list> -ENDIF:method_list - </contents> +<% end %> +<% end # classes["sections"] %> +<% end %> +<% if defined? classes and classes["includes"] then %> + <included-module-list> +<% classes["includes"].each do |includes| %> + <included-module name="<%= includes["name"] %>" +<% if includes["aref"] then %> + href="<%= includes["aref"] %>" +<% end %> + /> +<% end # classes["includes"] %> + </included-module-list> +<% end %> + </contents> } ######################################################################## @@ -75,38 +76,36 @@ ENDIF:method_list ONE_PAGE = %{<?xml version="1.0" encoding="utf-8"?> <rdoc> <file-list> -START:files - <file name="%short_name%" id="%href%"> +<% values["files"].each do |files| %> + <file name="<%= files["short_name"] %>" id="<%= files["href"] %>"> <file-info> - <path>%full_path%</path> - <dtm-modified>%dtm_modified%</dtm-modified> + <path><%= files["full_path"] %></path> + <dtm-modified><%= files["dtm_modified"] %></dtm-modified> </file-info> } + CONTENTS_XML + %{ </file> -END:files +<% end # values["files"] %> </file-list> <class-module-list> -START:classes - <%classmod% name="%full_name%" id="%full_name%"> +<% values["classes"].each do |classes| %> + <<%= classes["classmod"] %> name="<%= classes["full_name"] %>" id="<%= classes["full_name"] %>"> <classmod-info> -IF:infiles +<% if classes["infiles"] then %> <infiles> -START:infiles - <infile>HREF:full_path_url:full_path:</infile> -END:infiles +<% classes["infiles"].each do |infiles| %> + <infile><%= href infiles["full_path_url"], infiles["full_path"] %></infile> +<% end # classes["infiles"] %> </infiles> -ENDIF:infiles -IF:parent - <superclass>HREF:par_url:parent:</superclass> -ENDIF:parent +<% end %> +<% if classes["parent"] then %> + <superclass><%= href classes["par_url"], classes["parent"] %></superclass> +<% end %> </classmod-info> } + CONTENTS_XML + %{ - </%classmod%> -END:classes + </<%= classes["classmod"] %>> +<% end # values["classes"] %> </class-module-list> </rdoc> } - -end end diff --git a/lib/rdoc/template.rb b/lib/rdoc/template.rb index dcbccea30..09fe1e8d2 100644 --- a/lib/rdoc/template.rb +++ b/lib/rdoc/template.rb @@ -1,233 +1,62 @@ -# Cheap-n-cheerful HTML page template system. You create a -# template containing: -# -# * variable names between percent signs (<tt>%fred%</tt>) -# * blocks of repeating stuff: -# -# START:key -# ... stuff -# END:key -# -# You feed the code a hash. For simple variables, the values -# are resolved directly from the hash. For blocks, the hash entry -# corresponding to +key+ will be an array of hashes. The block will -# be generated once for each entry. Blocks can be nested arbitrarily -# deeply. -# -# The template may also contain -# -# IF:key -# ... stuff -# ENDIF:key +require 'erb' + +## +# An ERB wrapper. # -# _stuff_ will only be included in the output if the corresponding -# key is set in the value hash. +# This TemplatePage operates similarly to RDoc 1.x's TemplatePage, but uses +# ERB instead of a custom template language. # -# Usage: Given a set of templates <tt>T1, T2,</tt> etc +# Converting from a RDoc 1.x template to an RDoc 2.x template is fairly easy. # -# values = { "name" => "Dave", state => "TX" } +# * %blah% becomes <%= values["blah"] %> +# * !INCLUDE! becomes <%= template_include %> +# * HREF:aref:name becomes <%= href values["aref"], values["name"] %> +# * IF:blah becomes <% if values["blah"] then %> +# * IFNOT:blah becomes <% unless values["blah"] then %> +# * ENDIF:blah becomes <% end %> +# * START:blah becomes <% values["blah"].each do |blah| %> +# * END:blah becomes <% end %> # -# t = TemplatePage.new(T1, T2, T3) -# File.open(name, "w") {|f| t.write_html_on(f, values)} -# or -# res = '' -# t.write_html_on(res, values) +# To make nested loops easier to convert, start by converting START statements +# to: # +# <% values["blah"].each do |blah| $stderr.puts blah.keys %> # +# So you can see what is being used inside which loop. class RDoc::TemplatePage - ########## - # A context holds a stack of key/value pairs (like a symbol - # table). When asked to resolve a key, it first searches the top of - # the stack, then the next level, and so on until it finds a match - # (or runs out of entries) - - class Context - def initialize - @stack = [] - end - - def push(hash) - @stack.push(hash) - end - - def pop - @stack.pop - end - - # Find a scalar value, throwing an exception if not found. This - # method is used when substituting the %xxx% constructs - - def find_scalar(key) - @stack.reverse_each do |level| - if val = level[key] - return val unless val.kind_of? Array - end - end - raise "Template error: can't find variable '#{key}'" - end - - # Lookup any key in the stack of hashes - - def lookup(key) - @stack.reverse_each do |level| - val = level[key] - return val if val - end - nil - end - end - - ######### - # Simple class to read lines out of a string - - class LineReader - # we're initialized with an array of lines - def initialize(lines) - @lines = lines - end - - # read the next line - def read - @lines.shift - end - - # Return a list of lines up to the line that matches - # a pattern. That last line is discarded. - def read_up_to(pattern) - res = [] - while line = read - if pattern.match(line) - return LineReader.new(res) - else - res << line - end - end - raise "Missing end tag in template: #{pattern.source}" - end - - # Return a copy of ourselves that can be modified without - # affecting us - def dup - LineReader.new(@lines.dup) - end - end - - - - # +templates+ is an array of strings containing the templates. - # We start at the first, and substitute in subsequent ones - # where the string <tt>!INCLUDE!</tt> occurs. For example, - # we could have the overall page template containing - # - # <html><body> - # <h1>Master</h1> - # !INCLUDE! - # </bost></html> - # - # and substitute subpages in to it by passing [master, sub_page]. - # This gives us a cheap way of framing pages + ## + # Create a new TemplatePage that will use +templates+. def initialize(*templates) - result = "!INCLUDE!" - templates.each do |content| - result.sub!(/!INCLUDE!/, content) - end - @lines = LineReader.new(result.split($/)) - end - - # Render the templates into HTML, storing the result on +op+ - # using the method <tt><<</tt>. The <tt>value_hash</tt> contains - # key/value pairs used to drive the substitution (as described above) - - def write_html_on(op, value_hash) - @context = Context.new - op << substitute_into(@lines, value_hash).tr("\000", '\\') + @templates = templates end + ## + # Returns "<a href=\"#{ref}\">#{name}</a>" - # Substitute a set of key/value pairs into the given template. - # Keys with scalar values have them substituted directly into - # the page. Those with array values invoke <tt>substitute_array</tt> - # (below), which examples a block of the template once for each - # row in the array. - # - # This routine also copes with the <tt>IF:</tt>_key_ directive, - # removing chunks of the template if the corresponding key - # does not appear in the hash, and the START: directive, which - # loops its contents for each value in an array - - def substitute_into(lines, values) - @context.push(values) - skip_to = nil - result = [] - - while line = lines.read - - case line - - when /^IF:(\w+)/ - lines.read_up_to(/^ENDIF:#$1/) unless @context.lookup($1) - - when /^IFNOT:(\w+)/ - lines.read_up_to(/^ENDIF:#$1/) if @context.lookup($1) - - when /^ENDIF:/ - ; - - when /^START:(\w+)/ - tag = $1 - body = lines.read_up_to(/^END:#{tag}/) - inner_values = @context.lookup(tag) - raise "unknown tag: #{tag}" unless inner_values - raise "not array: #{tag}" unless inner_values.kind_of?(Array) - inner_values.each do |vals| - result << substitute_into(body.dup, vals) - end - else - result << expand_line(line.dup) - end + def href(ref, name) + if ref then + "<a href=\"#{ref}\">#{name}</a>" + else + name end - - @context.pop - - result.join("\n") end - # Given an individual line, we look for %xxx% constructs and - # HREF:ref:name: constructs, substituting for each. - - def expand_line(line) - # Generate a cross reference if a reference is given, - # otherwise just fill in the name part + ## + # Process the template using +values+, writing the result to +io+. - line.gsub!(/HREF:(\w+?):(\w+?):/) { - ref = @context.lookup($1) - name = @context.find_scalar($2) + def write_html_on(io, values) + template_include = "" - if ref and !ref.kind_of?(Array) - "<a href=\"#{ref}\">#{name}</a>" - else - name - end - } - - # Substitute in values for %xxx% constructs. This is made complex - # because the replacement string may contain characters that are - # meaningful to the regexp (like \1) - - line = line.gsub(/%([a-zA-Z]\w*)%/) { - val = @context.find_scalar($1) - val.tr('\\', "\000") - } + b = binding + @templates.reverse_each do |template| + template_include = ERB.new(template).result b + end - line - rescue Exception => e - $stderr.puts "Error in template: #{e}" - $stderr.puts "Original line: #{line}" - exit + io.write template_include end end |