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: 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__ ).expand_path.dirname
VERSION =

Release Version

'1.1.5'

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

def generate( toplevels )
	@outputdir = Pathname.new( @options.op_dir ).expand_path( @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.message, 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( 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 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( 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



148
149
# File 'lib/rdoc/generator/darkfish.rb', line 148

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, :noop => $dryrun )
	end
end