Class: RDoc::Generator::Darkfish

Inherits:
XML
  • Object
show all
Includes:
ERB::Util
Defined in:
lib/rdoc/generator/darkfish.rb

Overview

A erb-based RDoc HTML generator

Constant Summary collapse

SVNRev =

Subversion rev

%$Rev: 24 $
SVNId =

Subversion ID

%$Id: darkfish.rb 24 2008-08-14 00:59:07Z deveiant $
GENERATOR_DIR =

Path to this file’s parent directory. Used to find templates and other resources.

Pathname.new( __FILE__ ).expand_path.dirname
VERSION =

Darkfish Version (update this in )

'1.1.2'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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.expand_path

  super
end

Instance Attribute Details

#outputdirObject (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( options )
  new( options )
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_directoriesObject

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
# File 'lib/rdoc/generator/darkfish.rb', line 130

def generate( toplevels )
  @outputdir = Pathname.new( @options.op_dir ).expand_path( @basedir )
    @files, @classes = RDoc::Generator::Context.build_indicies( toplevels, @options )

  # Now actually write the output
  generate_xhtml( @options, @files, @classes )

rescue StandardError => err
  debug_msg "%s: %s\n  %s" % [ err.class.name, err.message, err.backtrace.join("\n  ") ]
  raise
end

#generate_xhtml(options, files, classes) ⇒ Object

Generate output



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/rdoc/generator/darkfish.rb', line 149

def generate_xhtml( options, 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 
  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( options, files_by_path, classes_by_classname )
  self.generate_class_files( options, files_by_path, classes_by_classname )
  self.generate_file_files( options, files_by_path, classes_by_classname )
end

#load_html_templateObject

No-opped



144
145
# File 'lib/rdoc/generator/darkfish.rb', line 144

def load_html_template # :nodoc:
end

#write_style_sheetObject

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 )
  end
end