rdoc 2.4.3 → 2.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rdoc might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/.autotest +3 -1
- data/History.txt +68 -0
- data/LICENSE.txt +57 -0
- data/Manifest.txt +37 -19
- data/README.txt +2 -12
- data/Rakefile +12 -12
- data/bin/rdoc +4 -4
- data/lib/rdoc.rb +32 -9
- data/lib/rdoc/alias.rb +2 -2
- data/lib/rdoc/any_method.rb +108 -16
- data/lib/rdoc/attr.rb +87 -1
- data/lib/rdoc/class_module.rb +131 -5
- data/lib/rdoc/code_object.rb +28 -5
- data/lib/rdoc/constant.rb +22 -0
- data/lib/rdoc/context.rb +80 -37
- data/lib/rdoc/gauntlet.rb +48 -0
- data/lib/rdoc/generator/darkfish.rb +25 -23
- data/lib/rdoc/generator/markup.rb +6 -29
- data/lib/rdoc/generator/ri.rb +39 -189
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +17 -1
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +10 -0
- data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/rdoc.css +38 -33
- data/lib/rdoc/include.rb +22 -0
- data/lib/rdoc/markup.rb +10 -262
- data/lib/rdoc/markup/attribute_manager.rb +57 -50
- data/lib/rdoc/markup/blank_line.rb +19 -0
- data/lib/rdoc/markup/document.rb +72 -0
- data/lib/rdoc/markup/formatter.rb +118 -0
- data/lib/rdoc/markup/formatter_test_case.rb +341 -0
- data/lib/rdoc/markup/heading.rb +17 -0
- data/lib/rdoc/markup/inline.rb +6 -5
- data/lib/rdoc/markup/list.rb +78 -0
- data/lib/rdoc/markup/list_item.rb +83 -0
- data/lib/rdoc/markup/paragraph.rb +66 -0
- data/lib/rdoc/markup/parser.rb +528 -0
- data/lib/rdoc/markup/rule.rb +17 -0
- data/lib/rdoc/markup/to_ansi.rb +72 -0
- data/lib/rdoc/markup/to_bs.rb +74 -0
- data/lib/rdoc/markup/to_html.rb +106 -172
- data/lib/rdoc/markup/to_html_crossref.rb +10 -4
- data/lib/rdoc/markup/to_rdoc.rb +243 -0
- data/lib/rdoc/markup/to_test.rb +27 -16
- data/lib/rdoc/markup/verbatim.rb +42 -0
- data/lib/rdoc/normal_class.rb +38 -1
- data/lib/rdoc/normal_module.rb +38 -8
- data/lib/rdoc/options.rb +39 -151
- data/lib/rdoc/parser.rb +36 -18
- data/lib/rdoc/parser/c.rb +102 -109
- data/lib/rdoc/parser/ruby.rb +359 -1662
- data/lib/rdoc/parser/ruby_tools.rb +157 -0
- data/lib/rdoc/parser/simple.rb +0 -2
- data/lib/rdoc/rdoc.rb +142 -82
- data/lib/rdoc/ri.rb +10 -0
- data/lib/rdoc/ri/driver.rb +674 -444
- data/lib/rdoc/ri/formatter.rb +2 -651
- data/lib/rdoc/ri/paths.rb +70 -45
- data/lib/rdoc/ri/store.rb +248 -0
- data/lib/rdoc/ruby_lex.rb +1284 -0
- data/lib/rdoc/ruby_token.rb +416 -0
- data/lib/rdoc/single_class.rb +5 -0
- data/lib/rdoc/stats.rb +152 -83
- data/lib/rdoc/task.rb +27 -49
- data/lib/rdoc/text.rb +130 -0
- data/lib/rdoc/tokenstream.rb +28 -9
- data/lib/rdoc/top_level.rb +49 -43
- data/test/hidden.zip.txt +1 -0
- data/test/test_attribute_manager.rb +9 -16
- data/test/test_rdoc_any_method.rb +23 -0
- data/test/test_rdoc_attr.rb +40 -0
- data/test/test_rdoc_class_module.rb +100 -0
- data/test/test_rdoc_code_object.rb +18 -2
- data/test/test_rdoc_context.rb +41 -0
- data/test/test_rdoc_generator_ri.rb +56 -0
- data/test/test_rdoc_markup.rb +21 -610
- data/test/test_rdoc_markup_attribute_manager.rb +14 -17
- data/test/test_rdoc_markup_document.rb +51 -0
- data/test/test_rdoc_markup_paragraph.rb +27 -0
- data/test/test_rdoc_markup_parser.rb +1327 -0
- data/test/test_rdoc_markup_to_ansi.rb +426 -0
- data/test/test_rdoc_markup_to_bs.rb +443 -0
- data/test/test_rdoc_markup_to_html.rb +183 -18
- data/test/test_rdoc_markup_to_html_crossref.rb +1 -3
- data/test/test_rdoc_markup_to_rdoc.rb +426 -0
- data/test/test_rdoc_normal_class.rb +17 -0
- data/test/test_rdoc_normal_module.rb +6 -6
- data/test/test_rdoc_options.rb +41 -0
- data/test/test_rdoc_parser.rb +66 -13
- data/test/test_rdoc_parser_c.rb +93 -38
- data/test/test_rdoc_parser_perl.rb +2 -3
- data/test/test_rdoc_parser_ruby.rb +291 -28
- data/test/test_rdoc_parser_simple.rb +48 -0
- data/test/test_rdoc_rdoc.rb +66 -0
- data/test/test_rdoc_ri_driver.rb +752 -38
- data/test/test_rdoc_ri_paths.rb +39 -0
- data/test/test_rdoc_ri_store.rb +309 -0
- data/test/test_rdoc_text.rb +157 -0
- data/test/test_rdoc_top_level.rb +35 -9
- data/test/xref_data.rb +9 -1
- data/test/xref_test_case.rb +8 -3
- metadata +110 -38
- metadata.gz.sig +0 -0
- data/lib/rdoc/cache.rb +0 -41
- data/lib/rdoc/diagram.rb +0 -340
- data/lib/rdoc/dot.rb +0 -249
- data/lib/rdoc/markup/fragments.rb +0 -377
- data/lib/rdoc/markup/lines.rb +0 -156
- data/lib/rdoc/markup/to_flow.rb +0 -211
- data/lib/rdoc/markup/to_latex.rb +0 -328
- data/lib/rdoc/markup/to_texinfo.rb +0 -73
- data/lib/rdoc/ri/cache.rb +0 -187
- data/lib/rdoc/ri/descriptions.rb +0 -156
- data/lib/rdoc/ri/display.rb +0 -340
- data/lib/rdoc/ri/reader.rb +0 -106
- data/lib/rdoc/ri/util.rb +0 -79
- data/lib/rdoc/ri/writer.rb +0 -68
- data/test/test_rdoc_ri_attribute_formatter.rb +0 -44
- data/test/test_rdoc_ri_default_display.rb +0 -302
- data/test/test_rdoc_ri_formatter.rb +0 -320
- data/test/test_rdoc_ri_html_formatter.rb +0 -141
- data/test/test_rdoc_ri_overstrike_formatter.rb +0 -71
data/lib/rdoc/code_object.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
require 'rdoc'
|
2
|
+
require 'rdoc/text'
|
2
3
|
|
3
4
|
##
|
5
|
+
# Base class for the RDoc code tree.
|
6
|
+
#
|
4
7
|
# We contain the common stuff for contexts (which are containers) and other
|
5
8
|
# elements (methods, attributes and so on)
|
6
9
|
|
7
10
|
class RDoc::CodeObject
|
8
11
|
|
12
|
+
include RDoc::Text
|
13
|
+
|
9
14
|
##
|
10
15
|
# Our comment
|
11
16
|
|
@@ -71,11 +76,13 @@ class RDoc::CodeObject
|
|
71
76
|
# Creates a new CodeObject that will document itself and its children
|
72
77
|
|
73
78
|
def initialize
|
74
|
-
@comment =
|
75
|
-
|
76
|
-
@
|
77
|
-
@
|
79
|
+
@comment = ''
|
80
|
+
|
81
|
+
@document_children = true
|
82
|
+
@document_self = true
|
83
|
+
@done_documenting = false
|
78
84
|
@force_documentation = false
|
85
|
+
|
79
86
|
@parent = nil
|
80
87
|
end
|
81
88
|
|
@@ -83,7 +90,16 @@ class RDoc::CodeObject
|
|
83
90
|
# Replaces our comment with +comment+, unless it is empty.
|
84
91
|
|
85
92
|
def comment=(comment)
|
86
|
-
@comment =
|
93
|
+
@comment = case comment
|
94
|
+
when NilClass then ''
|
95
|
+
when RDoc::Markup::Document then comment
|
96
|
+
else
|
97
|
+
if comment and not comment.empty? then
|
98
|
+
normalize_comment comment
|
99
|
+
else
|
100
|
+
@comment
|
101
|
+
end
|
102
|
+
end
|
87
103
|
end
|
88
104
|
|
89
105
|
##
|
@@ -104,6 +120,13 @@ class RDoc::CodeObject
|
|
104
120
|
remove_methods_etc unless document_self
|
105
121
|
end
|
106
122
|
|
123
|
+
##
|
124
|
+
# Does this class have a comment with content or is document_self false.
|
125
|
+
|
126
|
+
def documented?
|
127
|
+
!(@document_self and @comment.empty?)
|
128
|
+
end
|
129
|
+
|
107
130
|
##
|
108
131
|
# File name of our parent
|
109
132
|
|
data/lib/rdoc/constant.rb
CHANGED
@@ -25,6 +25,28 @@ class RDoc::Constant < RDoc::CodeObject
|
|
25
25
|
self.comment = comment
|
26
26
|
end
|
27
27
|
|
28
|
+
##
|
29
|
+
# Constants are ordered by name
|
30
|
+
|
31
|
+
def <=> other
|
32
|
+
return unless self.class === other
|
33
|
+
|
34
|
+
[parent_name, name] <=> [other.parent_name, other.name]
|
35
|
+
end
|
36
|
+
|
37
|
+
def == other
|
38
|
+
self.class == other.class and
|
39
|
+
@parent == other.parent and
|
40
|
+
@name == other.name
|
41
|
+
end
|
42
|
+
|
43
|
+
def inspect # :nodoc:
|
44
|
+
"#<%s:0x%x %s::%s>" % [
|
45
|
+
self.class, object_id,
|
46
|
+
parent_name, @name,
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
28
50
|
##
|
29
51
|
# Path to this constant
|
30
52
|
|
data/lib/rdoc/context.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'thread'
|
2
1
|
require 'rdoc/code_object'
|
3
2
|
|
4
3
|
##
|
@@ -8,6 +7,8 @@ require 'rdoc/code_object'
|
|
8
7
|
|
9
8
|
class RDoc::Context < RDoc::CodeObject
|
10
9
|
|
10
|
+
include Comparable
|
11
|
+
|
11
12
|
##
|
12
13
|
# Types of methods
|
13
14
|
|
@@ -107,7 +108,6 @@ class RDoc::Context < RDoc::CodeObject
|
|
107
108
|
attr_reader :title
|
108
109
|
|
109
110
|
@@sequence = "SEC00000"
|
110
|
-
@@sequence_lock = Mutex.new
|
111
111
|
|
112
112
|
##
|
113
113
|
# Creates a new section with +title+ and +comment+
|
@@ -116,10 +116,8 @@ class RDoc::Context < RDoc::CodeObject
|
|
116
116
|
@parent = parent
|
117
117
|
@title = title
|
118
118
|
|
119
|
-
@@
|
120
|
-
|
121
|
-
@sequence = @@sequence.dup
|
122
|
-
end
|
119
|
+
@@sequence.succ!
|
120
|
+
@sequence = @@sequence.dup
|
123
121
|
|
124
122
|
set_comment comment
|
125
123
|
end
|
@@ -239,16 +237,24 @@ class RDoc::Context < RDoc::CodeObject
|
|
239
237
|
end
|
240
238
|
|
241
239
|
##
|
242
|
-
#
|
240
|
+
# Turns +an_alias+ into an AnyMethod that points to +meth+
|
243
241
|
|
244
242
|
def add_alias_impl(an_alias, meth)
|
245
243
|
new_meth = RDoc::AnyMethod.new an_alias.text, an_alias.new_name
|
246
244
|
new_meth.is_alias_for = meth
|
247
245
|
new_meth.singleton = meth.singleton
|
248
246
|
new_meth.params = meth.params
|
249
|
-
|
247
|
+
|
248
|
+
new_meth.comment = an_alias.comment
|
249
|
+
|
250
250
|
meth.add_alias new_meth
|
251
|
+
|
251
252
|
add_method new_meth
|
253
|
+
|
254
|
+
# aliases don't use ongoing visibility
|
255
|
+
new_meth.visibility = meth.visibility
|
256
|
+
|
257
|
+
new_meth
|
252
258
|
end
|
253
259
|
|
254
260
|
##
|
@@ -268,25 +274,30 @@ class RDoc::Context < RDoc::CodeObject
|
|
268
274
|
def add_class(class_type, name, superclass = 'Object')
|
269
275
|
klass = add_class_or_module @classes, class_type, name, superclass
|
270
276
|
|
277
|
+
existing = klass.superclass
|
278
|
+
existing = existing.name if existing and not String === existing
|
279
|
+
|
280
|
+
if superclass != existing and superclass != 'Object' then
|
281
|
+
klass.superclass = superclass
|
282
|
+
end
|
283
|
+
|
271
284
|
# If the parser encounters Container::Item before encountering
|
272
285
|
# Container, then it assumes that Container is a module. This may not
|
273
286
|
# be the case, so remove Container from the module list if present and
|
274
287
|
# transfer any contained classes and modules to the new class.
|
275
288
|
|
276
|
-
RDoc::TopLevel.
|
277
|
-
mod = RDoc::TopLevel.modules_hash.delete klass.full_name
|
289
|
+
mod = RDoc::TopLevel.modules_hash.delete klass.full_name
|
278
290
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
@modules.delete klass.name
|
285
|
-
end
|
291
|
+
if mod then
|
292
|
+
klass.classes_hash.update mod.classes_hash
|
293
|
+
klass.modules_hash.update mod.modules_hash
|
294
|
+
klass.method_list.concat mod.method_list
|
286
295
|
|
287
|
-
|
296
|
+
@modules.delete klass.name
|
288
297
|
end
|
289
298
|
|
299
|
+
RDoc::TopLevel.classes_hash[klass.full_name] = klass
|
300
|
+
|
290
301
|
klass
|
291
302
|
end
|
292
303
|
|
@@ -295,27 +306,20 @@ class RDoc::Context < RDoc::CodeObject
|
|
295
306
|
# classes Hash +collection+.
|
296
307
|
|
297
308
|
def add_class_or_module(collection, class_type, name, superclass = nil)
|
298
|
-
full_name =
|
299
|
-
|
300
|
-
else
|
301
|
-
"#{self.full_name}::#{name}"
|
302
|
-
end
|
309
|
+
full_name = child_name name
|
310
|
+
|
303
311
|
mod = collection[name]
|
304
312
|
|
305
313
|
if mod then
|
306
314
|
mod.superclass = superclass unless mod.module?
|
307
315
|
else
|
308
|
-
all =
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
else
|
314
|
-
RDoc::TopLevel.classes_hash
|
315
|
-
end
|
316
|
+
all = if class_type == RDoc::NormalModule then
|
317
|
+
RDoc::TopLevel.modules_hash
|
318
|
+
else
|
319
|
+
RDoc::TopLevel.classes_hash
|
320
|
+
end
|
316
321
|
|
317
|
-
|
318
|
-
end
|
322
|
+
mod = all[full_name]
|
319
323
|
|
320
324
|
unless mod then
|
321
325
|
mod = class_type.new name, superclass
|
@@ -329,9 +333,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
329
333
|
end
|
330
334
|
|
331
335
|
unless @done_documenting then
|
332
|
-
|
333
|
-
all[full_name] = mod
|
334
|
-
end
|
336
|
+
all[full_name] = mod
|
335
337
|
collection[name] = mod
|
336
338
|
end
|
337
339
|
|
@@ -384,6 +386,29 @@ class RDoc::Context < RDoc::CodeObject
|
|
384
386
|
add_class_or_module @modules, class_type, name, nil
|
385
387
|
end
|
386
388
|
|
389
|
+
##
|
390
|
+
# Adds an alias from +from+ to +name+
|
391
|
+
|
392
|
+
def add_module_alias from, name
|
393
|
+
to_name = child_name name
|
394
|
+
|
395
|
+
unless @done_documenting then
|
396
|
+
if from.module? then
|
397
|
+
RDoc::TopLevel.modules_hash
|
398
|
+
else
|
399
|
+
RDoc::TopLevel.classes_hash
|
400
|
+
end[to_name] = from
|
401
|
+
|
402
|
+
if from.module? then
|
403
|
+
@modules
|
404
|
+
else
|
405
|
+
@classes
|
406
|
+
end[name] = from
|
407
|
+
end
|
408
|
+
|
409
|
+
from
|
410
|
+
end
|
411
|
+
|
387
412
|
##
|
388
413
|
# Adds +require+ to this context's top level
|
389
414
|
|
@@ -404,6 +429,17 @@ class RDoc::Context < RDoc::CodeObject
|
|
404
429
|
thing.section = @current_section
|
405
430
|
end
|
406
431
|
|
432
|
+
##
|
433
|
+
# Creates the full name for a child with +name+
|
434
|
+
|
435
|
+
def child_name name
|
436
|
+
if RDoc::TopLevel === self then
|
437
|
+
name
|
438
|
+
else
|
439
|
+
"#{self.full_name}::#{name}"
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
407
443
|
##
|
408
444
|
# Array of classes in this context
|
409
445
|
|
@@ -436,7 +472,7 @@ class RDoc::Context < RDoc::CodeObject
|
|
436
472
|
# Iterator for attributes
|
437
473
|
|
438
474
|
def each_attribute # :yields: attribute
|
439
|
-
@attributes.each {|a| yield a}
|
475
|
+
@attributes.each { |a| yield a }
|
440
476
|
end
|
441
477
|
|
442
478
|
##
|
@@ -582,6 +618,13 @@ class RDoc::Context < RDoc::CodeObject
|
|
582
618
|
result
|
583
619
|
end
|
584
620
|
|
621
|
+
##
|
622
|
+
# The full name for this context. This method is overridden by subclasses.
|
623
|
+
|
624
|
+
def full_name
|
625
|
+
'(unknown)'
|
626
|
+
end
|
627
|
+
|
585
628
|
##
|
586
629
|
# URL for this with a +prefix+
|
587
630
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rdoc/rdoc'
|
2
|
+
require 'gauntlet'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
##
|
6
|
+
# Allows for testing of RDoc against every gem
|
7
|
+
|
8
|
+
class RDoc::Gauntlet < Gauntlet
|
9
|
+
|
10
|
+
def run name
|
11
|
+
next if self.data[name]
|
12
|
+
|
13
|
+
ri_dir = File.expand_path "~/.gauntlet/data/ri/#{name}"
|
14
|
+
FileUtils.rm_rf ri_dir if File.exist? ri_dir
|
15
|
+
|
16
|
+
yaml = File.read 'gemspec'
|
17
|
+
spec = Gem::Specification.from_yaml yaml
|
18
|
+
|
19
|
+
args = %W[--ri --op #{ri_dir}]
|
20
|
+
args.push(*spec.rdoc_options)
|
21
|
+
args << spec.require_paths
|
22
|
+
args << spec.extra_rdoc_files
|
23
|
+
args = args.flatten.map { |a| a.to_s }
|
24
|
+
args.delete '--quiet'
|
25
|
+
|
26
|
+
puts "#{name} - rdoc #{args.join ' '}"
|
27
|
+
|
28
|
+
self.dirty = true
|
29
|
+
r = RDoc::RDoc.new
|
30
|
+
|
31
|
+
begin
|
32
|
+
r.document args
|
33
|
+
self.data[name] = true
|
34
|
+
puts 'passed'
|
35
|
+
rescue StandardError, RDoc::Error => e
|
36
|
+
puts "failed - (#{e.class}) #{e.message}"
|
37
|
+
self.data[name] = false
|
38
|
+
end
|
39
|
+
rescue Gem::Exception
|
40
|
+
puts "bad gem #{name}"
|
41
|
+
ensure
|
42
|
+
puts
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
RDoc::Gauntlet.new.run_the_gauntlet if $0 == __FILE__
|
48
|
+
|
@@ -2,18 +2,17 @@
|
|
2
2
|
# vim: noet ts=2 sts=8 sw=2
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
gem 'rdoc', '>= 2.4' unless defined?
|
5
|
+
gem 'rdoc', '>= 2.4' unless ENV['RDOC_TEST'] or defined?($rdoc_rakefile)
|
6
6
|
|
7
7
|
require 'pp'
|
8
8
|
require 'pathname'
|
9
9
|
require 'fileutils'
|
10
10
|
require 'erb'
|
11
|
-
require 'yaml'
|
12
11
|
|
13
|
-
require 'rdoc/rdoc'
|
14
|
-
require 'rdoc/generator'
|
15
12
|
require 'rdoc/generator/markup'
|
16
13
|
|
14
|
+
$DARKFISH_DRYRUN = false # TODO make me non-global
|
15
|
+
|
17
16
|
#
|
18
17
|
# Darkfish RDoc HTML Generator
|
19
18
|
#
|
@@ -98,12 +97,11 @@ class RDoc::Generator::Darkfish
|
|
98
97
|
### Initialize a few instance variables before we start
|
99
98
|
def initialize( options )
|
100
99
|
@options = options
|
101
|
-
@options.diagram = false
|
102
100
|
|
103
101
|
template = @options.template || 'darkfish'
|
104
102
|
|
105
103
|
template_dir = $LOAD_PATH.map do |path|
|
106
|
-
File.join path, GENERATOR_DIR, 'template', template
|
104
|
+
File.join File.expand_path(path), GENERATOR_DIR, 'template', template
|
107
105
|
end.find do |dir|
|
108
106
|
File.directory? dir
|
109
107
|
end
|
@@ -151,7 +149,7 @@ class RDoc::Generator::Darkfish
|
|
151
149
|
### directory.
|
152
150
|
def write_style_sheet
|
153
151
|
debug_msg "Copying static files"
|
154
|
-
options = { :verbose => $DEBUG_RDOC, :noop => $
|
152
|
+
options = { :verbose => $DEBUG_RDOC, :noop => $DARKFISH_DRYRUN }
|
155
153
|
|
156
154
|
FileUtils.cp @template_dir + 'rdoc.css', '.', options
|
157
155
|
|
@@ -223,12 +221,14 @@ class RDoc::Generator::Darkfish
|
|
223
221
|
### Generate an index page which lists all the classes which
|
224
222
|
### are documented.
|
225
223
|
def generate_index
|
224
|
+
template_file = @template_dir + 'index.rhtml'
|
225
|
+
return unless template_file.exist?
|
226
|
+
|
226
227
|
debug_msg "Rendering the index page..."
|
227
228
|
|
228
|
-
|
229
|
-
template_src = templatefile.read
|
229
|
+
template_src = template_file.read
|
230
230
|
template = ERB.new( template_src, nil, '<>' )
|
231
|
-
template.filename =
|
231
|
+
template.filename = template_file.to_s
|
232
232
|
context = binding()
|
233
233
|
|
234
234
|
output = nil
|
@@ -237,14 +237,14 @@ class RDoc::Generator::Darkfish
|
|
237
237
|
output = template.result( context )
|
238
238
|
rescue NoMethodError => err
|
239
239
|
raise RDoc::Error, "Error while evaluating %s: %s (at %p)" % [
|
240
|
-
|
240
|
+
template_file,
|
241
241
|
err.message,
|
242
242
|
eval( "_erbout[-50,50]", context )
|
243
243
|
], err.backtrace
|
244
244
|
end
|
245
245
|
|
246
246
|
outfile = @basedir + @options.op_dir + 'index.html'
|
247
|
-
unless $
|
247
|
+
unless $DARKFISH_DRYRUN
|
248
248
|
debug_msg "Outputting to %s" % [outfile.expand_path]
|
249
249
|
outfile.open( 'w', 0644 ) do |fh|
|
250
250
|
fh.print( output )
|
@@ -256,8 +256,9 @@ class RDoc::Generator::Darkfish
|
|
256
256
|
|
257
257
|
### Generate a documentation file for each class
|
258
258
|
def generate_class_files
|
259
|
+
template_file = @template_dir + 'classpage.rhtml'
|
260
|
+
return unless template_file.exist?
|
259
261
|
debug_msg "Generating class documentation in #@outputdir"
|
260
|
-
templatefile = @template_dir + 'classpage.rhtml'
|
261
262
|
|
262
263
|
@classes.each do |klass|
|
263
264
|
debug_msg " working on %s (%s)" % [ klass.full_name, klass.path ]
|
@@ -266,14 +267,15 @@ class RDoc::Generator::Darkfish
|
|
266
267
|
svninfo = self.get_svninfo( klass )
|
267
268
|
|
268
269
|
debug_msg " rendering #{outfile}"
|
269
|
-
self.render_template(
|
270
|
+
self.render_template( template_file, binding(), outfile )
|
270
271
|
end
|
271
272
|
end
|
272
273
|
|
273
274
|
### Generate a documentation file for each file
|
274
275
|
def generate_file_files
|
276
|
+
template_file = @template_dir + 'filepage.rhtml'
|
277
|
+
return unless template_file.exist?
|
275
278
|
debug_msg "Generating file documentation in #@outputdir"
|
276
|
-
templatefile = @template_dir + 'filepage.rhtml'
|
277
279
|
|
278
280
|
@files.each do |file|
|
279
281
|
outfile = @outputdir + file.path
|
@@ -282,7 +284,7 @@ class RDoc::Generator::Darkfish
|
|
282
284
|
context = binding()
|
283
285
|
|
284
286
|
debug_msg " rendering #{outfile}"
|
285
|
-
self.render_template(
|
287
|
+
self.render_template( template_file, binding(), outfile )
|
286
288
|
end
|
287
289
|
end
|
288
290
|
|
@@ -335,26 +337,26 @@ class RDoc::Generator::Darkfish
|
|
335
337
|
end
|
336
338
|
|
337
339
|
|
338
|
-
### Load and render the erb template in the given +
|
340
|
+
### Load and render the erb template in the given +template_file+ within the
|
339
341
|
### specified +context+ (a Binding object) and write it out to +outfile+.
|
340
|
-
### Both +
|
342
|
+
### Both +template_file+ and +outfile+ should be Pathname-like objects.
|
341
343
|
|
342
|
-
def render_template(
|
343
|
-
template_src =
|
344
|
+
def render_template( template_file, context, outfile )
|
345
|
+
template_src = template_file.read
|
344
346
|
template = ERB.new( template_src, nil, '<>' )
|
345
|
-
template.filename =
|
347
|
+
template.filename = template_file.to_s
|
346
348
|
|
347
349
|
output = begin
|
348
350
|
template.result( context )
|
349
351
|
rescue NoMethodError => err
|
350
352
|
raise RDoc::Error, "Error while evaluating %s: %s (at %p)" % [
|
351
|
-
|
353
|
+
template_file.to_s,
|
352
354
|
err.message,
|
353
355
|
eval( "_erbout[-50,50]", context )
|
354
356
|
], err.backtrace
|
355
357
|
end
|
356
358
|
|
357
|
-
unless $
|
359
|
+
unless $DARKFISH_DRYRUN
|
358
360
|
outfile.dirname.mkpath
|
359
361
|
outfile.open( 'w', 0644 ) do |ofh|
|
360
362
|
ofh.print( output )
|