rdoc 2.5.2 → 2.5.3
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/History.txt +12 -2
- data/Manifest.txt +1 -0
- data/lib/rdoc.rb +1 -1
- data/lib/rdoc/markup/preprocess.rb +2 -3
- data/lib/rdoc/parser/simple.rb +8 -1
- data/lib/rdoc/rdoc.rb +39 -30
- data/test/test_rdoc_markup_pre_process.rb +42 -0
- data/test/test_rdoc_parser_simple.rb +19 -0
- data/test/test_rdoc_rdoc.rb +90 -1
- metadata +5 -3
- metadata.gz.sig +3 -1
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
=== 2.5.
|
1
|
+
=== 2.5.3 / 2010-04
|
2
2
|
|
3
3
|
*NOTE*:
|
4
4
|
|
@@ -19,7 +19,17 @@ To have ri data for you gems you'll also need to run:
|
|
19
19
|
|
20
20
|
If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc.
|
21
21
|
|
22
|
-
* 1 Minor
|
22
|
+
* 1 Minor Enhancement
|
23
|
+
* RDoc::Parser::Simple and the include directive remove coding: comment from
|
24
|
+
first line
|
25
|
+
* 2 Bug Fixe
|
26
|
+
* Fixed loading of created.rid when regenerating documentation. Ruby bug
|
27
|
+
#3121 by Yusuke Endoh.
|
28
|
+
* Compare times as Integers as created.rid doesn't store fractional times.
|
29
|
+
|
30
|
+
=== 2.5.2 / 2010-04-09
|
31
|
+
|
32
|
+
* 1 Minor Enhancement
|
23
33
|
* Imported various changes by Nobu from ruby trunk.
|
24
34
|
* 2 Bug Fixes
|
25
35
|
* RDoc parses files without extensions as text files again.
|
data/Manifest.txt
CHANGED
@@ -121,6 +121,7 @@ test/test_rdoc_markup_attribute_manager.rb
|
|
121
121
|
test/test_rdoc_markup_document.rb
|
122
122
|
test/test_rdoc_markup_paragraph.rb
|
123
123
|
test/test_rdoc_markup_parser.rb
|
124
|
+
test/test_rdoc_markup_pre_process.rb
|
124
125
|
test/test_rdoc_markup_to_ansi.rb
|
125
126
|
test/test_rdoc_markup_to_bs.rb
|
126
127
|
test/test_rdoc_markup_to_html.rb
|
data/lib/rdoc.rb
CHANGED
@@ -41,14 +41,13 @@ class RDoc::Markup::PreProcess
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
private
|
45
|
-
|
46
44
|
##
|
47
45
|
# Include a file, indenting it correctly.
|
48
46
|
|
49
47
|
def include_file(name, indent)
|
50
48
|
if full_name = find_include_file(name) then
|
51
49
|
content = File.read full_name
|
50
|
+
content = content.sub(/\A# .*coding[=:].*$/, '').lstrip
|
52
51
|
|
53
52
|
# strip leading '#'s, but only if all lines start with them
|
54
53
|
if content =~ /^[^#]/ then
|
@@ -57,7 +56,7 @@ class RDoc::Markup::PreProcess
|
|
57
56
|
content.gsub(/^#?/, indent)
|
58
57
|
end
|
59
58
|
else
|
60
|
-
|
59
|
+
warn "Couldn't find file to include '#{name}' from #{@input_file_name}"
|
61
60
|
''
|
62
61
|
end
|
63
62
|
end
|
data/lib/rdoc/parser/simple.rb
CHANGED
@@ -24,7 +24,10 @@ class RDoc::Parser::Simple < RDoc::Parser
|
|
24
24
|
# Extract the file contents and attach them to the TopLevel as a comment
|
25
25
|
|
26
26
|
def scan
|
27
|
-
|
27
|
+
comment = remove_coding_comment @content
|
28
|
+
comment = remove_private_comments comment
|
29
|
+
|
30
|
+
@top_level.comment = comment
|
28
31
|
@top_level.parser = self.class
|
29
32
|
@top_level
|
30
33
|
end
|
@@ -33,5 +36,9 @@ class RDoc::Parser::Simple < RDoc::Parser
|
|
33
36
|
comment.gsub(/^--\n.*?^\+\+/m, '').sub(/^--\n.*/m, '')
|
34
37
|
end
|
35
38
|
|
39
|
+
def remove_coding_comment text
|
40
|
+
text.sub(/\A# .*coding[=:].*$/, '')
|
41
|
+
end
|
42
|
+
|
36
43
|
end
|
37
44
|
|
data/lib/rdoc/rdoc.rb
CHANGED
@@ -37,6 +37,11 @@ class RDoc::RDoc
|
|
37
37
|
|
38
38
|
attr_accessor :generator
|
39
39
|
|
40
|
+
##
|
41
|
+
# Hash of files and their last modified times.
|
42
|
+
|
43
|
+
attr_reader :last_modified
|
44
|
+
|
40
45
|
##
|
41
46
|
# RDoc options
|
42
47
|
|
@@ -75,13 +80,13 @@ class RDoc::RDoc
|
|
75
80
|
end
|
76
81
|
|
77
82
|
def initialize
|
78
|
-
@current
|
79
|
-
@exclude
|
80
|
-
@generator
|
81
|
-
@
|
82
|
-
@old_siginfo
|
83
|
-
@options
|
84
|
-
@stats
|
83
|
+
@current = nil
|
84
|
+
@exclude = nil
|
85
|
+
@generator = nil
|
86
|
+
@last_modified = {}
|
87
|
+
@old_siginfo = nil
|
88
|
+
@options = nil
|
89
|
+
@stats = nil
|
85
90
|
end
|
86
91
|
|
87
92
|
##
|
@@ -132,35 +137,39 @@ class RDoc::RDoc
|
|
132
137
|
# contain the flag file <tt>created.rid</tt> then we refuse to use it, as
|
133
138
|
# we may clobber some manually generated documentation
|
134
139
|
|
135
|
-
def setup_output_dir(
|
136
|
-
flag_file = output_flag_file
|
140
|
+
def setup_output_dir(dir, force)
|
141
|
+
flag_file = output_flag_file dir
|
137
142
|
|
138
143
|
last = {}
|
139
144
|
|
140
|
-
if File.exist?
|
141
|
-
unless File.directory?
|
142
|
-
|
143
|
-
end
|
145
|
+
if File.exist? dir then
|
146
|
+
error "#{dir} exists and is not a directory" unless File.directory? dir
|
147
|
+
|
144
148
|
begin
|
145
149
|
open flag_file do |io|
|
146
|
-
unless force
|
147
|
-
Time.parse
|
150
|
+
unless force then
|
151
|
+
Time.parse io.gets
|
152
|
+
|
148
153
|
io.each do |line|
|
149
|
-
file, time = line.split
|
154
|
+
file, time = line.split "\t", 2
|
150
155
|
time = Time.parse(time) rescue next
|
151
156
|
last[file] = time
|
152
157
|
end
|
153
158
|
end
|
154
159
|
end
|
155
|
-
rescue
|
156
|
-
error
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
160
|
+
rescue SystemCallError, TypeError
|
161
|
+
error <<-ERROR
|
162
|
+
|
163
|
+
Directory #{dir} already exists, but it looks like it isn't an RDoc directory.
|
164
|
+
|
165
|
+
Because RDoc doesn't want to risk destroying any of your existing files,
|
166
|
+
you'll need to specify a different output directory name (using the --op <dir>
|
167
|
+
option)
|
168
|
+
|
169
|
+
ERROR
|
161
170
|
end
|
162
171
|
else
|
163
|
-
FileUtils.mkdir_p
|
172
|
+
FileUtils.mkdir_p dir
|
164
173
|
end
|
165
174
|
|
166
175
|
last
|
@@ -170,7 +179,7 @@ class RDoc::RDoc
|
|
170
179
|
# Update the flag file in an output directory.
|
171
180
|
|
172
181
|
def update_output_dir(op_dir, time, last = {})
|
173
|
-
|
182
|
+
open output_flag_file(op_dir), "w" do |f|
|
174
183
|
f.puts time.rfc2822
|
175
184
|
last.each do |n, t|
|
176
185
|
f.puts "#{n}\t#{t.rfc2822}"
|
@@ -226,12 +235,12 @@ class RDoc::RDoc
|
|
226
235
|
|
227
236
|
case type = stat.ftype
|
228
237
|
when "file" then
|
229
|
-
next if
|
230
|
-
stat.mtime <=
|
238
|
+
next if last_modified = @last_modified[rel_file_name] and
|
239
|
+
stat.mtime.to_i <= last_modified.to_i
|
231
240
|
|
232
241
|
if force_doc or RDoc::Parser.can_parse(rel_file_name) then
|
233
242
|
file_list << rel_file_name.sub(/^\.\//, '')
|
234
|
-
@
|
243
|
+
@last_modified[rel_file_name] = stat.mtime
|
235
244
|
end
|
236
245
|
when "directory" then
|
237
246
|
next if rel_file_name == "CVS" || rel_file_name == ".svn"
|
@@ -356,7 +365,7 @@ The internal error was:
|
|
356
365
|
|
357
366
|
@exclude = @options.exclude
|
358
367
|
|
359
|
-
@
|
368
|
+
@last_modified = setup_output_dir @options.op_dir, @options.force_update
|
360
369
|
|
361
370
|
start_time = Time.now
|
362
371
|
|
@@ -382,7 +391,7 @@ The internal error was:
|
|
382
391
|
self.class.current = self
|
383
392
|
|
384
393
|
@generator.generate file_info
|
385
|
-
update_output_dir ".", start_time, @
|
394
|
+
update_output_dir ".", start_time, @last_modified
|
386
395
|
ensure
|
387
396
|
self.class.current = nil
|
388
397
|
end
|
@@ -396,7 +405,7 @@ The internal error was:
|
|
396
405
|
end
|
397
406
|
|
398
407
|
def read_file_contents(filename)
|
399
|
-
content =
|
408
|
+
content = open filename, "rb" do |f| f.read end
|
400
409
|
|
401
410
|
if defined? Encoding then
|
402
411
|
if /coding[=:]\s*([^\s;]+)/i =~ content[%r"\A(?:#!.*\n)?.*\n"]
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'rdoc/markup/preprocess'
|
5
|
+
|
6
|
+
class TestRDocMarkupPreProcess < MiniTest::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@tempfile = Tempfile.new 'test_rdoc_markup_pre_process'
|
10
|
+
@name = File.basename @tempfile.path
|
11
|
+
@dir = File.dirname @tempfile.path
|
12
|
+
|
13
|
+
@pp = RDoc::Markup::PreProcess.new __FILE__, [@dir]
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
@tempfile.close
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_include_file
|
21
|
+
@tempfile.write <<-INCLUDE
|
22
|
+
# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
|
23
|
+
|
24
|
+
Regular expressions (<i>regexp</i>s) are patterns which describe the
|
25
|
+
contents of a string.
|
26
|
+
INCLUDE
|
27
|
+
|
28
|
+
@tempfile.flush
|
29
|
+
@tempfile.rewind
|
30
|
+
|
31
|
+
content = @pp.include_file @name, ''
|
32
|
+
|
33
|
+
expected = <<-EXPECTED
|
34
|
+
Regular expressions (<i>regexp</i>s) are patterns which describe the
|
35
|
+
contents of a string.
|
36
|
+
EXPECTED
|
37
|
+
|
38
|
+
assert_equal expected, content
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
@@ -22,6 +22,25 @@ class TestRDocParserSimple < MiniTest::Unit::TestCase
|
|
22
22
|
@tempfile.close
|
23
23
|
end
|
24
24
|
|
25
|
+
def test_remove_coding_comment
|
26
|
+
parser = util_parser <<-TEXT
|
27
|
+
# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
|
28
|
+
|
29
|
+
Regular expressions (<i>regexp</i>s) are patterns which describe the
|
30
|
+
contents of a string.
|
31
|
+
TEXT
|
32
|
+
|
33
|
+
parser.scan
|
34
|
+
|
35
|
+
expected = <<-TEXT.strip
|
36
|
+
|
37
|
+
Regular expressions (<i>regexp</i>s) are patterns which describe the
|
38
|
+
contents of a string.
|
39
|
+
TEXT
|
40
|
+
|
41
|
+
assert_equal expected, @top_level.comment
|
42
|
+
end
|
43
|
+
|
25
44
|
def test_remove_private_comments
|
26
45
|
parser = util_parser ''
|
27
46
|
text = "foo\n\n--\nbar\n++\n\nbaz\n"
|
data/test/test_rdoc_rdoc.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'tempfile'
|
2
|
+
require 'tmpdir'
|
2
3
|
require 'rubygems'
|
3
4
|
require 'minitest/autorun'
|
4
5
|
require 'rdoc/rdoc'
|
@@ -11,7 +12,7 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def teardown
|
14
|
-
@tempfile.close
|
15
|
+
@tempfile.close rescue nil # HACK for 1.8.6
|
15
16
|
end
|
16
17
|
|
17
18
|
def test_gather_files
|
@@ -19,6 +20,24 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
|
|
19
20
|
assert_equal [file], @rdoc.gather_files([file, file])
|
20
21
|
end
|
21
22
|
|
23
|
+
def test_normalized_file_list
|
24
|
+
files = @rdoc.normalized_file_list [__FILE__]
|
25
|
+
|
26
|
+
files = files.map { |file| File.expand_path file }
|
27
|
+
|
28
|
+
assert_equal [File.expand_path(__FILE__)], files
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_normalized_file_list_not_modified
|
32
|
+
files = [__FILE__]
|
33
|
+
|
34
|
+
@rdoc.last_modified[__FILE__] = File.stat(__FILE__).mtime
|
35
|
+
|
36
|
+
files = @rdoc.normalized_file_list [__FILE__]
|
37
|
+
|
38
|
+
assert_empty files
|
39
|
+
end
|
40
|
+
|
22
41
|
def test_read_file_contents
|
23
42
|
@tempfile.write "hi everybody"
|
24
43
|
@tempfile.flush
|
@@ -62,5 +81,75 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
|
|
62
81
|
assert_empty @rdoc.remove_unparseable file_list
|
63
82
|
end
|
64
83
|
|
84
|
+
def test_setup_output_dir
|
85
|
+
path = @tempfile.path
|
86
|
+
@tempfile.unlink
|
87
|
+
|
88
|
+
last = @rdoc.setup_output_dir path, false
|
89
|
+
|
90
|
+
assert_empty last
|
91
|
+
|
92
|
+
assert File.directory? path
|
93
|
+
ensure
|
94
|
+
FileUtils.rm_f path
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_setup_output_dir_exists
|
98
|
+
path = @tempfile.path
|
99
|
+
@tempfile.unlink
|
100
|
+
FileUtils.mkdir_p path
|
101
|
+
|
102
|
+
open @rdoc.output_flag_file(path), 'w' do |io|
|
103
|
+
io.puts Time.at 0
|
104
|
+
io.puts "./lib/rdoc.rb\t#{Time.at 86400}"
|
105
|
+
end
|
106
|
+
|
107
|
+
last = @rdoc.setup_output_dir path, false
|
108
|
+
|
109
|
+
assert_equal 1, last.size
|
110
|
+
assert_equal Time.at(86400), last['./lib/rdoc.rb']
|
111
|
+
ensure
|
112
|
+
FileUtils.rm_f path
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_setup_output_dir_exists_empty_created_rid
|
116
|
+
path = @tempfile.path
|
117
|
+
@tempfile.unlink
|
118
|
+
FileUtils.mkdir_p path
|
119
|
+
|
120
|
+
open @rdoc.output_flag_file(path), 'w' do end
|
121
|
+
|
122
|
+
e = assert_raises RDoc::Error do
|
123
|
+
@rdoc.setup_output_dir path, false
|
124
|
+
end
|
125
|
+
|
126
|
+
assert_match %r%Directory #{Regexp.escape path} already exists%, e.message
|
127
|
+
ensure
|
128
|
+
FileUtils.rm_f path
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_setup_output_dir_exists_file
|
132
|
+
path = @tempfile.path
|
133
|
+
|
134
|
+
e = assert_raises RDoc::Error do
|
135
|
+
@rdoc.setup_output_dir path, false
|
136
|
+
end
|
137
|
+
|
138
|
+
assert_match(%r%#{Regexp.escape path} exists and is not a directory%,
|
139
|
+
e.message)
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_setup_output_dir_exists_not_rdoc
|
143
|
+
skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir
|
144
|
+
|
145
|
+
Dir.mktmpdir do |dir|
|
146
|
+
e = assert_raises RDoc::Error do
|
147
|
+
@rdoc.setup_output_dir dir, false
|
148
|
+
end
|
149
|
+
|
150
|
+
assert_match %r%Directory #{Regexp.escape dir} already exists%, e.message
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
65
154
|
end
|
66
155
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 2.5.
|
8
|
+
- 3
|
9
|
+
version: 2.5.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Eric Hodel
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
x52qPcexcYZR7w==
|
39
39
|
-----END CERTIFICATE-----
|
40
40
|
|
41
|
-
date: 2010-04-
|
41
|
+
date: 2010-04-10 00:00:00 -07:00
|
42
42
|
default_executable:
|
43
43
|
dependencies:
|
44
44
|
- !ruby/object:Gem::Dependency
|
@@ -246,6 +246,7 @@ files:
|
|
246
246
|
- test/test_rdoc_markup_document.rb
|
247
247
|
- test/test_rdoc_markup_paragraph.rb
|
248
248
|
- test/test_rdoc_markup_parser.rb
|
249
|
+
- test/test_rdoc_markup_pre_process.rb
|
249
250
|
- test/test_rdoc_markup_to_ansi.rb
|
250
251
|
- test/test_rdoc_markup_to_bs.rb
|
251
252
|
- test/test_rdoc_markup_to_html.rb
|
@@ -316,6 +317,7 @@ test_files:
|
|
316
317
|
- test/test_rdoc_markup_document.rb
|
317
318
|
- test/test_rdoc_markup_paragraph.rb
|
318
319
|
- test/test_rdoc_markup_parser.rb
|
320
|
+
- test/test_rdoc_markup_pre_process.rb
|
319
321
|
- test/test_rdoc_markup_to_ansi.rb
|
320
322
|
- test/test_rdoc_markup_to_bs.rb
|
321
323
|
- test/test_rdoc_markup_to_html.rb
|
metadata.gz.sig
CHANGED