CAMPING_EXTRAS_DIR = File.expand_path(File.dirname(__FILE__)) module Generators class HTMLGenerator def generate_html @files_and_classes = { 'allfiles' => gen_into_index(@files), 'allclasses' => gen_into_index(@classes), "initial_page" => main_url, 'realtitle' => CGI.escapeHTML(@options.title), 'charset' => @options.charset } # the individual descriptions for files and classes gen_into(@files) gen_into(@classes) gen_main_index # this method is defined in the template file write_extra_pages if defined? write_extra_pages end def gen_into(list) hsh = @files_and_classes.dup list.each do |item| if item.document_self op_file = item.path hsh['root'] = item.path.split("/").map { ".." }[1..-1].join("/") item.instance_variable_set("@values", hsh) File.makedirs(File.dirname(op_file)) File.open(op_file, "w") { |file| item.write_on(file) } end end end def gen_into_index(list) res = [] list.each do |item| hsh = item.value_hash hsh['href'] = item.path hsh['name'] = item.index_name res << hsh end res end def gen_main_index template = TemplatePage.new(RDoc::Page::INDEX) File.open("index.html", "w") do |f| values = @files_and_classes.dup if @options.inline_source values['inline_source'] = true end template.write_html_on(f, values) end ['Camping.gif', 'permalink.gif'].each do |img| ipath = File.join(CAMPING_EXTRAS_DIR, img) File.copy(ipath, img) end end end end module RDoc module Page ###################################################################### # # The following is used for the -1 option # FONTS = "verdana,arial,'Bitstream Vera Sans',helvetica,sans-serif" STYLE = %{ body, th, td { font: normal 14px verdana,arial,'Bitstream Vera Sans',helvetica,sans-serif; line-height: 160%; padding: 0; margin: 0; margin-bottom: 30px; /* background-color: #402; */ background-color: #694; } h1, h2, h3, h4 { font-family: Utopia, Georgia, serif; font-weight: bold; letter-spacing: -0.018em; } h1 { font-size: 24px; margin: .15em 1em 0 0 } h2 { font-size: 24px } h3 { font-size: 19px } h4 { font-size: 17px; font-weight: normal; } h4.ruled { border-bottom: solid 1px #CC9; } h2.ruled { padding-top: 35px; border-top: solid 1px #AA5; } /* Link styles */ :link, :visited { color: #00b; } :link:hover, :visited:hover { background-color: #eee; color: #B22; } #fullpage { width: 720px; margin: 0 auto; } .page_shade, .page { padding: 0px 5px 5px 0px; background-color: #fcfcf9; border: solid 1px #983; } .page { margin-left: -5px; margin-top: -5px; padding: 20px 35px; } .page .header { float: right; color: #777; font-size: 10px; } .page h1, .page h2, .page h3 { clear: both; text-align: center; } #pager { padding: 10px 4px; color: white; font-size: 11px; } #pager :link, #pager :visited { color: #bfb; padding: 0px 5px; } #pager :link:hover, #pager :visited:hover { background-color: #262; color: white; } #logo { float: left; } #menu { background-color: #dfa; padding: 4px 12px; margin: 0; } #menu h3 { padding: 0; margin: 0; } #menu #links { float: right; } pre { font-weight: bold; color: #730; } tt { color: #703; font-size: 12pt; } .dyn-source { background-color: #775915; padding: 4px 8px; margin: 0; display: none; } .dyn-source pre { color: #DDDDDD; font-size: 8pt; } .source-link { text-align: right; font-size: 8pt; } .ruby-comment { color: green; font-style: italic } .ruby-constant { color: #CCDDFF; font-weight: bold; } .ruby-identifier { color: #CCCCCC; } .ruby-ivar { color: #BBCCFF; } .ruby-keyword { color: #EEEEFF; font-weight: bold } .ruby-node { color: #FFFFFF; } .ruby-operator { color: #CCCCCC; } .ruby-regexp { color: #DDFFDD; } .ruby-value { color: #FFAAAA; font-style: italic } .kw { color: #DDDDFF; font-weight: bold } .cmt { color: #CCFFCC; font-style: italic } .str { color: #EECCCC; font-style: italic } .re { color: #EECCCC; } } CONTENTS_XML = %{ IF:description %description% ENDIF:description IF:requires

Requires:

ENDIF:requires IF:attributes

Attributes

START:attributes END:attributes
%name%%rw%%a_desc%
ENDIF:attributes IF:includes

Includes

ENDIF:includes START:sections IF:method_list

Methods

START:method_list IF:methods START:methods

%type% %category% method: IF:callseq %callseq% ENDIF:callseq IFNOT:callseq %name%%params%

ENDIF:callseq IF:m_desc %m_desc% ENDIF:m_desc IF:sourcecode
%sourcecode%
ENDIF:sourcecode END:methods ENDIF:methods END:method_list ENDIF:method_list END:sections } ############################################################################ BODY = %{ IF:title %realtitle% » %title% ENDIF:title IFNOT:title %realtitle% ENDIF:title
Files: START:allfiles %name% END:allfiles IF:allclasses | classes: START:allclasses %name% END:allclasses ENDIF:allclasses
!INCLUDE!
} ############################################################################### FILE_PAGE = <<_FILE_PAGE_
%full_path% / %dtm_modified%
#{CONTENTS_XML}
_FILE_PAGE_ ################################################################### CLASS_PAGE = %{
IF:parent

%classmod% %full_name% < HREF:par_url:parent:

ENDIF:parent IFNOT:parent

%classmod% %full_name%

ENDIF:parent IF:infiles (in files START:infiles HREF:full_path_url:full_path: END:infiles ) ENDIF:infiles } + CONTENTS_XML + %{
} ################################################################### METHOD_LIST = %{ IF:includes
Included modules

START:includes HREF:aref:name: END:includes
ENDIF:includes IF:method_list START:method_list IF:methods
%type% %category% methods
START:methods
IF:callseq %callseq% ENDIF:callseq IFNOT:callseq %name%%params% ENDIF:callseq IF:codeurl src ENDIF:codeurl
IF:m_desc
%m_desc%
ENDIF:m_desc IF:aka
This method is also aliased as START:aka %name% END:aka
ENDIF:aka IF:sourcecode
%sourcecode%
ENDIF:sourcecode END:methods ENDIF:methods END:method_list ENDIF:method_list } ########################## Index ################################ FR_INDEX_BODY = %{ !INCLUDE! } FILE_INDEX = %{ START:entries %name%
END:entries } CLASS_INDEX = FILE_INDEX METHOD_INDEX = FILE_INDEX INDEX = %{ %realtitle% Click here to open the Camping docs. } end end