rdoc 2.5 → 2.5.1
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 +1 -1
- data/History.txt +41 -8
- data/Manifest.txt +1 -0
- data/lib/rdoc.rb +7 -7
- data/lib/rdoc/any_method.rb +24 -8
- data/lib/rdoc/attr.rb +13 -0
- data/lib/rdoc/class_module.rb +5 -3
- data/lib/rdoc/code_object.rb +0 -19
- data/lib/rdoc/generator/darkfish.rb +44 -42
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +5 -5
- data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +7 -7
- data/lib/rdoc/generator/template/darkfish/rdoc.css +2 -2
- data/lib/rdoc/markup.rb +7 -7
- data/lib/rdoc/markup/parser.rb +1 -1
- data/lib/rdoc/markup/preprocess.rb +1 -1
- data/lib/rdoc/markup/to_html.rb +1 -1
- data/lib/rdoc/options.rb +1 -1
- data/lib/rdoc/parser.rb +5 -5
- data/lib/rdoc/parser/c.rb +54 -17
- data/lib/rdoc/parser/perl.rb +8 -8
- data/lib/rdoc/parser/ruby.rb +24 -29
- data/lib/rdoc/rdoc.rb +30 -18
- data/lib/rdoc/ri/driver.rb +7 -15
- data/lib/rdoc/ri/paths.rb +1 -2
- data/lib/rdoc/ruby_lex.rb +12 -12
- data/lib/rdoc/ruby_token.rb +4 -4
- data/lib/rdoc/stats.rb +2 -2
- data/lib/rdoc/task.rb +9 -5
- data/test/test.txt +1 -0
- data/test/test_rdoc_any_method.rb +50 -8
- data/test/test_rdoc_attr.rb +8 -0
- data/test/test_rdoc_class_module.rb +1 -1
- data/test/test_rdoc_code_object.rb +2 -2
- data/test/test_rdoc_constant.rb +1 -1
- data/test/test_rdoc_context.rb +2 -2
- data/test/test_rdoc_include.rb +1 -1
- data/test/test_rdoc_markup_parser.rb +18 -0
- data/test/test_rdoc_markup_to_ansi.rb +1 -1
- data/test/test_rdoc_markup_to_html_crossref.rb +1 -1
- data/test/test_rdoc_markup_to_rdoc.rb +1 -1
- data/test/test_rdoc_normal_class.rb +1 -1
- data/test/test_rdoc_normal_module.rb +1 -1
- data/test/test_rdoc_parser.rb +2 -6
- data/test/test_rdoc_parser_c.rb +20 -0
- data/test/test_rdoc_parser_ruby.rb +1 -1
- data/test/test_rdoc_rdoc.rb +2 -2
- data/test/test_rdoc_require.rb +1 -1
- data/test/test_rdoc_ri_driver.rb +27 -6
- data/test/test_rdoc_ri_paths.rb +10 -6
- data/test/test_rdoc_task.rb +9 -9
- data/test/test_rdoc_top_level.rb +1 -1
- data/test/xref_data.rb +1 -1
- data/test/xref_test_case.rb +1 -1
- metadata +4 -2
- metadata.gz.sig +0 -0
data/lib/rdoc/rdoc.rb
CHANGED
@@ -78,7 +78,7 @@ class RDoc::RDoc
|
|
78
78
|
@current = nil
|
79
79
|
@exclude = nil
|
80
80
|
@generator = nil
|
81
|
-
@last_created =
|
81
|
+
@last_created = {}
|
82
82
|
@old_siginfo = nil
|
83
83
|
@options = nil
|
84
84
|
@stats = nil
|
@@ -135,20 +135,29 @@ class RDoc::RDoc
|
|
135
135
|
def setup_output_dir(op_dir, force)
|
136
136
|
flag_file = output_flag_file op_dir
|
137
137
|
|
138
|
+
last = {}
|
139
|
+
|
138
140
|
if File.exist? op_dir then
|
139
141
|
unless File.directory? op_dir then
|
140
142
|
error "'#{op_dir}' exists, and is not a directory"
|
141
143
|
end
|
142
144
|
begin
|
143
|
-
|
144
|
-
|
145
|
+
open flag_file do |io|
|
146
|
+
unless force
|
147
|
+
Time.parse f.gets
|
148
|
+
io.each do |line|
|
149
|
+
file, time = line.split(/\t/, 2)
|
150
|
+
time = Time.parse(time) rescue next
|
151
|
+
last[file] = time
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
rescue
|
145
156
|
error "\nDirectory #{op_dir} already exists, but it looks like it\n" +
|
146
157
|
"isn't an RDoc directory. Because RDoc doesn't want to risk\n" +
|
147
158
|
"destroying any of your existing files, you'll need to\n" +
|
148
159
|
"specify a different output directory name (using the\n" +
|
149
160
|
"--op <dir> option).\n\n"
|
150
|
-
else
|
151
|
-
last = (Time.parse(created) unless force rescue nil)
|
152
161
|
end
|
153
162
|
else
|
154
163
|
FileUtils.mkdir_p(op_dir)
|
@@ -160,8 +169,13 @@ class RDoc::RDoc
|
|
160
169
|
##
|
161
170
|
# Update the flag file in an output directory.
|
162
171
|
|
163
|
-
def update_output_dir(op_dir, time)
|
164
|
-
File.open(output_flag_file(op_dir), "w")
|
172
|
+
def update_output_dir(op_dir, time, last = {})
|
173
|
+
File.open(output_flag_file(op_dir), "w") do |f|
|
174
|
+
f.puts time.rfc2822
|
175
|
+
last.each do |n, t|
|
176
|
+
f.puts "#{n}\t#{t.rfc2822}"
|
177
|
+
end
|
178
|
+
end
|
165
179
|
end
|
166
180
|
|
167
181
|
##
|
@@ -211,18 +225,20 @@ class RDoc::RDoc
|
|
211
225
|
stat = File.stat rel_file_name rescue next
|
212
226
|
|
213
227
|
case type = stat.ftype
|
214
|
-
when "file"
|
215
|
-
next if
|
228
|
+
when "file" then
|
229
|
+
next if last_created = @last_created[rel_file_name] and
|
230
|
+
stat.mtime <= last_created
|
216
231
|
|
217
232
|
if force_doc or RDoc::Parser.can_parse(rel_file_name) then
|
218
233
|
file_list << rel_file_name.sub(/^\.\//, '')
|
234
|
+
@last_created[rel_file_name] = stat.mtime
|
219
235
|
end
|
220
|
-
when "directory"
|
236
|
+
when "directory" then
|
221
237
|
next if rel_file_name == "CVS" || rel_file_name == ".svn"
|
222
238
|
|
223
239
|
dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME
|
224
240
|
|
225
|
-
if File.file?
|
241
|
+
if File.file? dot_doc then
|
226
242
|
file_list << parse_dot_doc_file(rel_file_name, dot_doc)
|
227
243
|
else
|
228
244
|
file_list << list_files_in_directory(rel_file_name)
|
@@ -366,7 +382,7 @@ The internal error was:
|
|
366
382
|
self.class.current = self
|
367
383
|
|
368
384
|
@generator.generate file_info
|
369
|
-
update_output_dir ".", start_time
|
385
|
+
update_output_dir ".", start_time, @last_created
|
370
386
|
ensure
|
371
387
|
self.class.current = nil
|
372
388
|
end
|
@@ -380,14 +396,10 @@ The internal error was:
|
|
380
396
|
end
|
381
397
|
|
382
398
|
def read_file_contents(filename)
|
383
|
-
content =
|
384
|
-
File.open(filename, "r:ascii-8bit") { |f| f.read }
|
385
|
-
else
|
386
|
-
File.read filename
|
387
|
-
end
|
399
|
+
content = File.open(filename, "rb") { |f| f.read }
|
388
400
|
|
389
401
|
if defined? Encoding then
|
390
|
-
if /coding
|
402
|
+
if /coding[=:]\s*([^\s;]+)/i =~ content[%r"\A(?:#!.*\n)?.*\n"]
|
391
403
|
if enc = ::Encoding.find($1)
|
392
404
|
content.force_encoding(enc)
|
393
405
|
end
|
data/lib/rdoc/ri/driver.rb
CHANGED
@@ -532,7 +532,7 @@ Options may also be set in the 'RI' environment variable.
|
|
532
532
|
elsif selector then
|
533
533
|
# replace Foo with Foo:: as given
|
534
534
|
completions.delete klass
|
535
|
-
completions << "#{klass}#{selector}"
|
535
|
+
completions << "#{klass}#{selector}"
|
536
536
|
end
|
537
537
|
|
538
538
|
completions.push(*methods)
|
@@ -657,21 +657,13 @@ Options may also be set in the 'RI' environment variable.
|
|
657
657
|
end
|
658
658
|
out << RDoc::Markup::Rule.new(1)
|
659
659
|
|
660
|
-
if method.
|
661
|
-
|
662
|
-
|
663
|
-
out << RDoc::Markup::Verbatim.new(*
|
660
|
+
if method.arglists then
|
661
|
+
arglists = method.arglists.chomp.split "\n"
|
662
|
+
arglists = arglists.map { |line| [' ', line, "\n"] }
|
663
|
+
out << RDoc::Markup::Verbatim.new(*arglists.flatten)
|
664
|
+
out << RDoc::Markup::Rule.new(1)
|
664
665
|
end
|
665
666
|
|
666
|
-
if method.block_params then
|
667
|
-
out << RDoc::Markup::BlankLine.new if method.call_seq
|
668
|
-
params = "yields: #{method.block_params}"
|
669
|
-
out << RDoc::Markup::Verbatim.new(' ', params, "\n")
|
670
|
-
end
|
671
|
-
|
672
|
-
out << RDoc::Markup::Rule.new(1) if
|
673
|
-
method.call_seq or method.block_params
|
674
|
-
|
675
667
|
out << RDoc::Markup::BlankLine.new
|
676
668
|
out << method.comment
|
677
669
|
out << RDoc::Markup::BlankLine.new
|
@@ -793,7 +785,7 @@ Options may also be set in the 'RI' environment variable.
|
|
793
785
|
end
|
794
786
|
|
795
787
|
methods.each do |item|
|
796
|
-
yield(*item)
|
788
|
+
yield(*item) # :yields: store, klass, ancestor, types, method
|
797
789
|
end
|
798
790
|
|
799
791
|
self
|
data/lib/rdoc/ri/paths.rb
CHANGED
@@ -58,8 +58,7 @@ module RDoc::RI::Paths
|
|
58
58
|
def self.gemdirs
|
59
59
|
return @gemdirs if @gemdirs
|
60
60
|
|
61
|
-
require 'rubygems' unless defined?(Gem)
|
62
|
-
Gem::Enable
|
61
|
+
require 'rubygems' unless defined?(Gem)
|
63
62
|
|
64
63
|
# HACK dup'd from Gem.latest_partials and friends
|
65
64
|
all_paths = []
|
data/lib/rdoc/ruby_lex.rb
CHANGED
@@ -144,7 +144,7 @@ class RDoc::RubyLex
|
|
144
144
|
end
|
145
145
|
@seek += 1
|
146
146
|
if c == "\n"
|
147
|
-
@line_no += 1
|
147
|
+
@line_no += 1
|
148
148
|
@char_no = 0
|
149
149
|
else
|
150
150
|
@char_no += 1
|
@@ -181,10 +181,10 @@ class RDoc::RubyLex
|
|
181
181
|
c2 = @here_readed.pop
|
182
182
|
end
|
183
183
|
c = c2 unless c
|
184
|
-
@rests.unshift c #c =
|
184
|
+
@rests.unshift c #c =
|
185
185
|
@seek -= 1
|
186
186
|
if c == "\n"
|
187
|
-
@line_no -= 1
|
187
|
+
@line_no -= 1
|
188
188
|
if idx = @readed.reverse.index("\n")
|
189
189
|
@char_no = @readed.size - idx
|
190
190
|
else
|
@@ -394,7 +394,7 @@ class RDoc::RubyLex
|
|
394
394
|
end
|
395
395
|
|
396
396
|
@OP.def_rule("=begin",
|
397
|
-
proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
|
397
|
+
proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
|
398
398
|
|op, io|
|
399
399
|
@ltype = "="
|
400
400
|
res = ''
|
@@ -415,8 +415,8 @@ class RDoc::RubyLex
|
|
415
415
|
else
|
416
416
|
@continue = false
|
417
417
|
@lex_state = EXPR_BEG
|
418
|
-
until (@indent_stack.empty? ||
|
419
|
-
[TkLPAREN, TkLBRACK, TkLBRACE,
|
418
|
+
until (@indent_stack.empty? ||
|
419
|
+
[TkLPAREN, TkLBRACK, TkLBRACE,
|
420
420
|
TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
|
421
421
|
@indent_stack.pop
|
422
422
|
end
|
@@ -427,7 +427,7 @@ class RDoc::RubyLex
|
|
427
427
|
end
|
428
428
|
|
429
429
|
@OP.def_rules("*", "**",
|
430
|
-
"=", "==", "===",
|
430
|
+
"=", "==", "===",
|
431
431
|
"=~", "<=>",
|
432
432
|
"<", "<=",
|
433
433
|
">", ">=", ">>") do
|
@@ -641,8 +641,8 @@ class RDoc::RubyLex
|
|
641
641
|
@OP.def_rules(";") do
|
642
642
|
|op, io|
|
643
643
|
@lex_state = EXPR_BEG
|
644
|
-
until (@indent_stack.empty? ||
|
645
|
-
[TkLPAREN, TkLBRACK, TkLBRACE,
|
644
|
+
until (@indent_stack.empty? ||
|
645
|
+
[TkLPAREN, TkLBRACK, TkLBRACE,
|
646
646
|
TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
|
647
647
|
@indent_stack.pop
|
648
648
|
end
|
@@ -761,7 +761,7 @@ class RDoc::RubyLex
|
|
761
761
|
end
|
762
762
|
end
|
763
763
|
|
764
|
-
# @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do
|
764
|
+
# @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do
|
765
765
|
# |op, io|
|
766
766
|
# @indent += 1
|
767
767
|
# @lex_state = EXPR_FNAME
|
@@ -1149,7 +1149,7 @@ class RDoc::RubyLex
|
|
1149
1149
|
str << read_escape
|
1150
1150
|
end
|
1151
1151
|
|
1152
|
-
if PERCENT_PAREN.values.include?(@quoted)
|
1152
|
+
if PERCENT_PAREN.values.include?(@quoted)
|
1153
1153
|
if PERCENT_PAREN[ch] == @quoted
|
1154
1154
|
nest += 1
|
1155
1155
|
elsif ch == @quoted
|
@@ -1270,7 +1270,7 @@ class RDoc::RubyLex
|
|
1270
1270
|
escape << ch << read_escape
|
1271
1271
|
end
|
1272
1272
|
else
|
1273
|
-
# other characters
|
1273
|
+
# other characters
|
1274
1274
|
end
|
1275
1275
|
|
1276
1276
|
escape
|
data/lib/rdoc/ruby_token.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# irb/ruby-token.rb - ruby tokens
|
2
|
+
# irb/ruby-token.rb - ruby tokens
|
3
3
|
# $Release Version: 0.9.5$
|
4
4
|
# $Revision: 11708 $
|
5
5
|
# $Date: 2007-02-12 15:01:19 -0800 (Mon, 12 Feb 2007) $
|
@@ -211,7 +211,7 @@ module RDoc::RubyToken
|
|
211
211
|
IRB.fail TkReading2TokenNoKey, token
|
212
212
|
end
|
213
213
|
|
214
|
-
tk = Token(tk[0], value)
|
214
|
+
tk = Token(tk[0], value)
|
215
215
|
|
216
216
|
if tk.kind_of?(TkOp) then
|
217
217
|
tk.name = token
|
@@ -221,8 +221,8 @@ module RDoc::RubyToken
|
|
221
221
|
IRB.fail TkSymbol2TokenNoKey, token
|
222
222
|
end
|
223
223
|
|
224
|
-
tk = Token(tk[0], value)
|
225
|
-
else
|
224
|
+
tk = Token(tk[0], value)
|
225
|
+
else
|
226
226
|
if token.instance_method(:initialize).arity == 3 then
|
227
227
|
tk = token.new(@prev_seek, @prev_line_no, @prev_char_no)
|
228
228
|
tk.set_text value
|
data/lib/rdoc/stats.rb
CHANGED
@@ -190,10 +190,10 @@ class RDoc::Stats
|
|
190
190
|
line << (" " * padding) if padding > 0
|
191
191
|
|
192
192
|
$stdout.print("#{line}\r")
|
193
|
-
$stdout.flush
|
194
193
|
else
|
195
|
-
puts "#{progress_bar} #{filename}"
|
194
|
+
$stdout.puts "#{progress_bar} #{filename}"
|
196
195
|
end
|
196
|
+
$stdout.flush
|
197
197
|
end
|
198
198
|
|
199
199
|
def done_adding # :nodoc:
|
data/lib/rdoc/task.rb
CHANGED
@@ -160,24 +160,28 @@ class RDoc::Task < Rake::TaskLib
|
|
160
160
|
# Create the tasks defined by this task lib.
|
161
161
|
|
162
162
|
def define
|
163
|
-
desc "Build
|
163
|
+
desc "Build RDoc HTML files"
|
164
164
|
task rdoc_task_name
|
165
165
|
|
166
|
-
desc "
|
166
|
+
desc "Rebuild RDoc HTML files"
|
167
167
|
task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
|
168
168
|
|
169
169
|
desc "Remove RDoc HTML files"
|
170
170
|
task clobber_task_name do
|
171
|
-
rm_r rdoc_dir rescue nil
|
171
|
+
rm_r @rdoc_dir rescue nil
|
172
172
|
end
|
173
173
|
|
174
174
|
task :clobber => [clobber_task_name]
|
175
175
|
|
176
176
|
directory @rdoc_dir
|
177
177
|
|
178
|
+
rdoc_target_deps = [
|
179
|
+
@rdoc_files,
|
180
|
+
Rake.application.rakefile
|
181
|
+
].flatten.compact
|
182
|
+
|
178
183
|
task rdoc_task_name => [rdoc_target]
|
179
|
-
file rdoc_target =>
|
180
|
-
rm_r @rdoc_dir rescue nil
|
184
|
+
file rdoc_target => rdoc_target_deps do
|
181
185
|
@before_running_rdoc.call if @before_running_rdoc
|
182
186
|
args = option_list + @rdoc_files
|
183
187
|
|
data/test/test.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
test file
|
@@ -1,26 +1,43 @@
|
|
1
|
-
require '
|
1
|
+
require File.expand_path '../xref_test_case', __FILE__
|
2
2
|
|
3
3
|
class RDocAnyMethodTest < XrefTestCase
|
4
4
|
|
5
|
-
def
|
6
|
-
|
5
|
+
def test_arglists
|
6
|
+
m = RDoc::AnyMethod.new nil, 'method'
|
7
|
+
|
8
|
+
assert_nil m.arglists
|
9
|
+
|
10
|
+
m.params = "(a, b)"
|
11
|
+
m.block_params = "c, d"
|
12
|
+
|
13
|
+
assert_equal "method(a, b) { |c, d| ... }", m.arglists
|
14
|
+
|
15
|
+
call_seq = <<-SEQ
|
16
|
+
method(a) { |c| ... }
|
17
|
+
method(a, b) { |c, d| ... }
|
18
|
+
SEQ
|
19
|
+
|
20
|
+
m.call_seq = call_seq.dup
|
21
|
+
|
22
|
+
assert_equal call_seq, m.arglists
|
7
23
|
end
|
8
24
|
|
9
|
-
def
|
10
|
-
assert_equal 'C1', @c1.method_list.first.
|
11
|
-
assert_equal 'C1', @c1.method_list.last.parent_name
|
25
|
+
def test_full_name
|
26
|
+
assert_equal 'C1::m', @c1.method_list.first.full_name
|
12
27
|
end
|
13
28
|
|
14
29
|
def test_marshal_load
|
15
30
|
instance_method = Marshal.load Marshal.dump(@c1.method_list.last)
|
16
31
|
|
17
|
-
assert_equal 'C1#m',
|
18
|
-
assert_equal 'C1',
|
32
|
+
assert_equal 'C1#m', instance_method.full_name
|
33
|
+
assert_equal 'C1', instance_method.parent_name
|
34
|
+
assert_equal '(foo)', instance_method.params
|
19
35
|
|
20
36
|
class_method = Marshal.load Marshal.dump(@c1.method_list.first)
|
21
37
|
|
22
38
|
assert_equal 'C1::m', class_method.full_name
|
23
39
|
assert_equal 'C1', class_method.parent_name
|
40
|
+
assert_equal '()', class_method.params
|
24
41
|
end
|
25
42
|
|
26
43
|
def test_name
|
@@ -29,5 +46,30 @@ class RDocAnyMethodTest < XrefTestCase
|
|
29
46
|
assert_nil m.name
|
30
47
|
end
|
31
48
|
|
49
|
+
def test_param_seq
|
50
|
+
m = RDoc::AnyMethod.new nil, 'method'
|
51
|
+
m.parent = @c1
|
52
|
+
m.params = 'a'
|
53
|
+
|
54
|
+
assert_equal '(a)', m.param_seq
|
55
|
+
|
56
|
+
m.params = '(a)'
|
57
|
+
|
58
|
+
assert_equal '(a)', m.param_seq
|
59
|
+
|
60
|
+
m.params = "(a,\n b)"
|
61
|
+
|
62
|
+
assert_equal '(a, b)', m.param_seq
|
63
|
+
|
64
|
+
m.block_params = "c,\n d"
|
65
|
+
|
66
|
+
assert_equal '(a, b) { |c, d| ... }', m.param_seq
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_parent_name
|
70
|
+
assert_equal 'C1', @c1.method_list.first.parent_name
|
71
|
+
assert_equal 'C1', @c1.method_list.last.parent_name
|
72
|
+
end
|
73
|
+
|
32
74
|
end
|
33
75
|
|
data/test/test_rdoc_attr.rb
CHANGED
@@ -8,6 +8,10 @@ class TestRDocAttr < MiniTest::Unit::TestCase
|
|
8
8
|
@a = RDoc::Attr.new nil, 'attr', 'RW', ''
|
9
9
|
end
|
10
10
|
|
11
|
+
def test_arglists
|
12
|
+
assert_nil @a.arglists
|
13
|
+
end
|
14
|
+
|
11
15
|
def test_block_params
|
12
16
|
assert_nil @a.block_params
|
13
17
|
end
|
@@ -20,6 +24,10 @@ class TestRDocAttr < MiniTest::Unit::TestCase
|
|
20
24
|
assert_equal '(unknown)#attr', @a.full_name
|
21
25
|
end
|
22
26
|
|
27
|
+
def test_params
|
28
|
+
assert_nil @a.params
|
29
|
+
end
|
30
|
+
|
23
31
|
def test_singleton
|
24
32
|
refute @a.singleton
|
25
33
|
end
|
data/test/test_rdoc_constant.rb
CHANGED