Class: RDoc::Generator::Darkfish
- Inherits:
-
XML
- Object
- XML
- RDoc::Generator::Darkfish
- Includes:
- ERB::Util
- Defined in:
- lib/rdoc/generator/darkfish.rb
Overview
A erb-based RDoc HTML generator
Constant Summary collapse
- SVNRev =
Subversion rev
%$Rev: 35 $
- SVNId =
Subversion ID
%$Id: darkfish.rb 35 2008-09-22 15:14:43Z deveiant $
- GENERATOR_DIR =
Path to this file’s parent directory. Used to find templates and other resources.
Pathname.new( __FILE__ )..dirname
- VERSION =
Release Version
'1.1.5'
Instance Attribute Summary collapse
-
#outputdir ⇒ Object
readonly
The output directory.
Class Method Summary collapse
-
.for(options) ⇒ Object
Standard generator factory method.
Instance Method Summary collapse
-
#debug_msg(*msg) ⇒ Object
Output progress information if debugging is enabled.
-
#gen_sub_directories ⇒ Object
Create the directories the generated docs will live in if they don’t already exist.
-
#generate(toplevels) ⇒ Object
Build the initial indices and output objects based on an array of TopLevel objects containing the extracted information.
-
#generate_xhtml(options, files, classes) ⇒ Object
Generate output.
-
#initialize(*args) ⇒ Darkfish
constructor
Initialize a few instance variables before we start.
-
#load_html_template ⇒ Object
No-opped.
-
#write_style_sheet ⇒ Object
Copy over the stylesheet into the appropriate place in the output directory.
Constructor Details
#initialize(*args) ⇒ Darkfish
Initialize a few instance variables before we start
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rdoc/generator/darkfish.rb', line 79 def initialize( *args ) @template = nil @template_dir = GENERATOR_DIR + 'template/darkfish' @files = [] @classes = [] @hyperlinks = {} @basedir = Pathname.pwd. super end |
Instance Attribute Details
#outputdir ⇒ Object (readonly)
The output directory
98 99 100 |
# File 'lib/rdoc/generator/darkfish.rb', line 98 def outputdir @outputdir end |
Class Method Details
.for(options) ⇒ Object
Standard generator factory method
69 70 71 |
# File 'lib/rdoc/generator/darkfish.rb', line 69 def self::for( ) new( ) end |
Instance Method Details
#debug_msg(*msg) ⇒ Object
Output progress information if debugging is enabled
102 103 104 105 |
# File 'lib/rdoc/generator/darkfish.rb', line 102 def debug_msg( *msg ) return unless $DEBUG $stderr.puts( *msg ) end |
#gen_sub_directories ⇒ Object
Create the directories the generated docs will live in if they don’t already exist.
110 111 112 |
# File 'lib/rdoc/generator/darkfish.rb', line 110 def gen_sub_directories @outputdir.mkpath end |
#generate(toplevels) ⇒ Object
Build the initial indices and output objects based on an array of TopLevel objects containing the extracted information.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/rdoc/generator/darkfish.rb', line 130 def generate( toplevels ) @outputdir = Pathname.new( @options.op_dir ).( @basedir ) if RDoc::Generator::Context.respond_to?( :build_indicies) @files, @classes = RDoc::Generator::Context.build_indicies( toplevels, @options ) else @files, @classes = RDoc::Generator::Context.build_indices( toplevels, @options ) end # Now actually write the output generate_xhtml( @options, @files, @classes ) rescue StandardError => err debug_msg "%s: %s\n %s" % [ err.class.name, err., err.backtrace.join("\n ") ] raise end |
#generate_xhtml(options, files, classes) ⇒ Object
Generate output
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/rdoc/generator/darkfish.rb', line 153 def generate_xhtml( , files, classes ) files = gen_into( @files ) classes = gen_into( @classes ) # Make a hash of class info keyed by class name classes_by_classname = classes.inject({}) {|hash, classinfo| hash[ classinfo['full_name'] ] = classinfo hash[ classinfo['full_name'] ][:outfile] = classinfo['full_name'].gsub( /::/, '/' ) + '.html' hash } # Make a hash of file info keyed by path files_by_path = files.inject({}) {|hash, fileinfo| hash[ fileinfo['full_path'] ] = fileinfo hash[ fileinfo['full_path'] ][:outfile] = fileinfo['full_path'] + '.html' hash } self.write_style_sheet self.generate_index( , files_by_path, classes_by_classname ) self.generate_class_files( , files_by_path, classes_by_classname ) self.generate_file_files( , files_by_path, classes_by_classname ) end |
#load_html_template ⇒ Object
No-opped
148 149 |
# File 'lib/rdoc/generator/darkfish.rb', line 148 def load_html_template # :nodoc: end |
#write_style_sheet ⇒ Object
Copy over the stylesheet into the appropriate place in the output directory.
117 118 119 120 121 122 123 |
# File 'lib/rdoc/generator/darkfish.rb', line 117 def write_style_sheet debug_msg "Copying over static files" staticfiles = %w[rdoc.css js images] staticfiles.each do |path| FileUtils.cp_r( @template_dir + path, '.', :verbose => $DEBUG, :noop => $dryrun ) end end |