From cbbfe41bb6bbeaac1a7e6e39506df3ddd31c912c Mon Sep 17 00:00:00 2001 From: Magnus Holm Date: Fri, 23 Jan 2009 20:40:10 +0100 Subject: [PATCH] Update Flipbook to RDoc 2 --- Rakefile | 12 +- extras/flipbook.rb | 357 +++++++++++++++++++++++++++++ extras/flipbook_rdoc.rb | 491 ---------------------------------------- 3 files changed, 366 insertions(+), 494 deletions(-) create mode 100644 extras/flipbook.rb delete mode 100644 extras/flipbook_rdoc.rb diff --git a/Rakefile b/Rakefile index ebfe089..d181f3e 100644 --- a/Rakefile +++ b/Rakefile @@ -4,6 +4,14 @@ require 'rake/gempackagetask' require 'rake/rdoctask' require 'rake/testtask' require 'fileutils' +begin + gem 'rdoc', '~> 2.2' + require 'rdoc' + $:.unshift 'extras' +rescue Gem::LoadError + puts "RDoc 2.2 required to build docs" + puts "Please run `gem install rdoc`" +end include FileUtils NAME = "camping" @@ -30,7 +38,7 @@ end Rake::RDocTask.new do |rdoc| rdoc.rdoc_dir = 'doc/rdoc' rdoc.options += RDOC_OPTS - rdoc.template = "extras/flipbook_rdoc.rb" + rdoc.template = "flipbook" rdoc.main = "README" rdoc.title = "Camping, the Documentation" rdoc.rdoc_files.add ['README', 'CHANGELOG', 'COPYING', 'lib/camping.rb', 'lib/camping/*.rb'] @@ -41,7 +49,6 @@ task :after_doc do mv "lib/camping-mural.rb", "lib/camping.rb" cp "extras/Camping.gif", "doc/rdoc/" cp "extras/permalink.gif", "doc/rdoc/" - sh %{scp -r doc/rdoc/* #{ENV['USER']}@rubyforge.org:/var/www/gforge-projects/camping/} end spec = @@ -61,7 +68,6 @@ spec = s.add_dependency('markaby', '>=0.5') s.add_dependency('rack', '>=0.3') - s.add_dependency('metaid') s.required_ruby_version = '>= 1.8.2' s.files = %w(COPYING README Rakefile) + diff --git a/extras/flipbook.rb b/extras/flipbook.rb new file mode 100644 index 0000000..736d3bb --- /dev/null +++ b/extras/flipbook.rb @@ -0,0 +1,357 @@ +CAMPING_EXTRAS_DIR = File.expand_path(File.dirname(__FILE__)) +require 'rdoc/generator/html' + +module RDoc::Generator +[Class, File].each do |klass| + old = klass.instance_method(:value_hash) + klass.send(:define_method, :value_hash) { + old.bind(self).call + @values['root'] = @path.split("/").map { ".." }[1..-1].join("/") + @values + } +end + +module HTML::FLIPBOOK +###################################################################### +# +# 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 = %q{ +<%= values['description'] if values['description'] %> + +<% if values['requires'] %> +

Requires:

+ + + + <%= template_include %> + + + + +} + +############################################################################### + +FILE_PAGE = <<_FILE_PAGE_ +
+
+
+
<%= values['full_path'] %> / <%= values['dtm_modified'] %>
+
+#{CONTENTS_XML} +
+
+_FILE_PAGE_ + +################################################################### + +CLASS_PAGE = %{ +
+
+<% if values['parent'] %> +

<%= values['classmod'] %> <%= values['full_name'] %> < <%= href values['par_url'], values['parent'] %>

+<% else %> +

<%= values['classmod'] %> <%= values['full_name'] %>

+<% end %> + +<% if values['infiles'] %> + (in files + <% values['infiles'].each do |file| %> + <%= href file['full_path_url'], file['full_path'] %> + <% end %> + ) +<% end %> +} + CONTENTS_XML + %{ +
+
+} + +METHOD_LIST = "" +########################## Index ################################ + +FR_INDEX_BODY = %{ +<%= template_include %> +} + +FILE_INDEX = %{ + + + + + + + + +<% values['entries'].each do |entry| %> + <%= href entry['href'], entry['name'] %>
+<% end %> + +} + +CLASS_INDEX = FILE_INDEX +METHOD_INDEX = FILE_INDEX + +INDEX = %{ + + + +<%= values['realtitle'] %> + + +Click here to open the Camping docs. + + +} + +end +end diff --git a/extras/flipbook_rdoc.rb b/extras/flipbook_rdoc.rb deleted file mode 100644 index 4bc4fc6..0000000 --- a/extras/flipbook_rdoc.rb +++ /dev/null @@ -1,491 +0,0 @@ -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