rdoc 3.5.2 → 3.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 -0
- data/lib/rdoc.rb +1 -1
- data/lib/rdoc/encoding.rb +12 -3
- data/lib/rdoc/generator/darkfish.rb +29 -6
- data/lib/rdoc/markup/pre_process.rb +1 -1
- data/lib/rdoc/text.rb +20 -6
- data/test/test_rdoc_encoding.rb +35 -0
- data/test/test_rdoc_markup_pre_process.rb +26 -0
- data/test/test_rdoc_text.rb +67 -2
- metadata +4 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
=== 3.5.3 / 2010-02-06
|
2
|
+
|
3
|
+
* Bug fixes
|
4
|
+
* When including a file lossily force-transcode it to the output encoding
|
5
|
+
instead of crashing to preserve as much content as possible. Ruby Bug
|
6
|
+
#4376 by Yui NARUSE.
|
7
|
+
* Work around inconsistent encoding result from String#sub!, String#gsub!.
|
8
|
+
Related to Ruby Bug #4376.
|
9
|
+
* Work around inconsistent encoding result from String#[]=. Related to Ruby
|
10
|
+
Bug #4376.
|
11
|
+
* When Darkfish fails the file being generated is now reported.
|
12
|
+
|
1
13
|
=== 3.5.2 / 2010-02-04
|
2
14
|
|
3
15
|
* Deprecations
|
data/lib/rdoc.rb
CHANGED
data/lib/rdoc/encoding.rb
CHANGED
@@ -12,8 +12,11 @@ module RDoc::Encoding
|
|
12
12
|
#
|
13
13
|
# The content will be converted to the +encoding+. If the file cannot be
|
14
14
|
# converted a warning will be printed and nil will be returned.
|
15
|
+
#
|
16
|
+
# If +force_transcode+ is true the document will be transcoded and any
|
17
|
+
# unknown character in the target encoding will be replaced with '?'
|
15
18
|
|
16
|
-
def self.read_file filename, encoding
|
19
|
+
def self.read_file filename, encoding, force_transcode = false
|
17
20
|
content = open filename, "rb" do |f| f.read end
|
18
21
|
|
19
22
|
utf8 = content.sub!(/\A\xef\xbb\xbf/, '')
|
@@ -50,8 +53,14 @@ module RDoc::Encoding
|
|
50
53
|
warn "unknown encoding name \"#{$1}\" for #{filename}, skipping"
|
51
54
|
nil
|
52
55
|
rescue Encoding::UndefinedConversionError => e
|
53
|
-
|
54
|
-
|
56
|
+
if force_transcode then
|
57
|
+
content.force_encoding orig_encoding
|
58
|
+
content.encode! encoding, :undef => :replace, :replace => '?'
|
59
|
+
content
|
60
|
+
else
|
61
|
+
warn "unable to convert #{e.message} for #{filename}, skipping"
|
62
|
+
nil
|
63
|
+
end
|
55
64
|
rescue Errno::EISDIR, Errno::ENOENT
|
56
65
|
nil
|
57
66
|
end
|
@@ -46,7 +46,7 @@ require 'rdoc/generator/markup'
|
|
46
46
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
47
47
|
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
48
48
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
49
|
-
|
49
|
+
|
50
50
|
class RDoc::Generator::Darkfish
|
51
51
|
|
52
52
|
RDoc::RDoc.add_generator self
|
@@ -162,9 +162,9 @@ class RDoc::Generator::Darkfish
|
|
162
162
|
generate_class_files
|
163
163
|
generate_file_files
|
164
164
|
|
165
|
-
rescue
|
165
|
+
rescue => e
|
166
166
|
debug_msg "%s: %s\n %s" % [
|
167
|
-
|
167
|
+
e.class.name, e.message, e.backtrace.join("\n ")
|
168
168
|
]
|
169
169
|
|
170
170
|
raise
|
@@ -208,6 +208,12 @@ class RDoc::Generator::Darkfish
|
|
208
208
|
out_file = @basedir + @options.op_dir + 'index.html'
|
209
209
|
|
210
210
|
render_template template_file, out_file do |io| binding end
|
211
|
+
rescue => e
|
212
|
+
error = RDoc::Error.new \
|
213
|
+
"error generating index.html: #{e.message} (#{e.class})"
|
214
|
+
error.set_backtrace e.backtrace
|
215
|
+
|
216
|
+
raise error
|
211
217
|
end
|
212
218
|
|
213
219
|
##
|
@@ -216,9 +222,12 @@ class RDoc::Generator::Darkfish
|
|
216
222
|
def generate_class_files
|
217
223
|
template_file = @template_dir + 'classpage.rhtml'
|
218
224
|
return unless template_file.exist?
|
219
|
-
debug_msg "Generating class documentation in
|
225
|
+
debug_msg "Generating class documentation in #{@outputdir}"
|
226
|
+
|
227
|
+
current = nil
|
220
228
|
|
221
229
|
@classes.each do |klass|
|
230
|
+
current = klass
|
222
231
|
debug_msg " working on %s (%s)" % [klass.full_name, klass.path]
|
223
232
|
out_file = @outputdir + klass.path
|
224
233
|
# suppress 1.9.3 warning
|
@@ -228,6 +237,12 @@ class RDoc::Generator::Darkfish
|
|
228
237
|
debug_msg " rendering #{out_file}"
|
229
238
|
render_template template_file, out_file do |io| binding end
|
230
239
|
end
|
240
|
+
rescue => e
|
241
|
+
error = RDoc::Error.new \
|
242
|
+
"error generating #{current.path}: #{e.message} (#{e.class})"
|
243
|
+
error.set_backtrace e.backtrace
|
244
|
+
|
245
|
+
raise error
|
231
246
|
end
|
232
247
|
|
233
248
|
##
|
@@ -236,17 +251,25 @@ class RDoc::Generator::Darkfish
|
|
236
251
|
def generate_file_files
|
237
252
|
template_file = @template_dir + 'filepage.rhtml'
|
238
253
|
return unless template_file.exist?
|
239
|
-
debug_msg "Generating file documentation in
|
254
|
+
debug_msg "Generating file documentation in #{@outputdir}"
|
255
|
+
|
256
|
+
out_file = nil
|
240
257
|
|
241
258
|
@files.each do |file|
|
242
259
|
out_file = @outputdir + file.path
|
243
|
-
debug_msg " working on %s (%s)" % [
|
260
|
+
debug_msg " working on %s (%s)" % [file.full_name, out_file]
|
244
261
|
# suppress 1.9.3 warning
|
245
262
|
rel_prefix = rel_prefix = @outputdir.relative_path_from(out_file.dirname)
|
246
263
|
|
247
264
|
debug_msg " rendering #{out_file}"
|
248
265
|
render_template template_file, out_file do |io| binding end
|
249
266
|
end
|
267
|
+
rescue => e
|
268
|
+
error =
|
269
|
+
RDoc::Error.new "error generating #{out_file}: #{e.message} (#{e.class})"
|
270
|
+
error.set_backtrace e.backtrace
|
271
|
+
|
272
|
+
raise error
|
250
273
|
end
|
251
274
|
|
252
275
|
##
|
@@ -120,7 +120,7 @@ class RDoc::Markup::PreProcess
|
|
120
120
|
return ''
|
121
121
|
end
|
122
122
|
|
123
|
-
content = RDoc::Encoding.read_file full_name, encoding
|
123
|
+
content = RDoc::Encoding.read_file full_name, encoding, true
|
124
124
|
|
125
125
|
# strip magic comment
|
126
126
|
content = content.sub(/\A# .*coding[=:].*$/, '').lstrip
|
data/lib/rdoc/text.rb
CHANGED
@@ -46,7 +46,9 @@ module RDoc::Text
|
|
46
46
|
|
47
47
|
text.each_line do |line|
|
48
48
|
line.gsub!(/^(.{8}*?)([^\t\r\n]{0,7})\t/) do
|
49
|
-
"#{$1}#{$2}#{' ' * (8 - $2.size)}"
|
49
|
+
r = "#{$1}#{$2}#{' ' * (8 - $2.size)}"
|
50
|
+
r.force_encoding text.encoding if Object.const_defined? :Encoding
|
51
|
+
r
|
50
52
|
end until line !~ /\t/
|
51
53
|
|
52
54
|
expanded << line
|
@@ -69,8 +71,11 @@ module RDoc::Text
|
|
69
71
|
|
70
72
|
flush = []
|
71
73
|
|
74
|
+
empty = ''
|
75
|
+
empty.force_encoding text.encoding if Object.const_defined? :Encoding
|
76
|
+
|
72
77
|
text.each_line do |line|
|
73
|
-
line[/^ {0,#{indent}}/] =
|
78
|
+
line[/^ {0,#{indent}}/] = empty
|
74
79
|
flush << line
|
75
80
|
end
|
76
81
|
|
@@ -158,11 +163,20 @@ http://rubyforge.org/tracker/?atid=2472&group_id=627&func=browse
|
|
158
163
|
# Strips /* */ style comments
|
159
164
|
|
160
165
|
def strip_stars text
|
166
|
+
encoding = text.encoding if Object.const_defined? :Encoding
|
167
|
+
|
161
168
|
text = text.gsub %r%Document-method:\s+[\w:.#]+%, ''
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
169
|
+
|
170
|
+
space = ' '
|
171
|
+
space.force_encoding encoding if encoding
|
172
|
+
|
173
|
+
text.sub! %r%/\*+% do space * $&.length end
|
174
|
+
text.sub! %r%\*+/% do space * $&.length end
|
175
|
+
text.gsub! %r%^[ \t]*\*%m do space * $&.length end
|
176
|
+
|
177
|
+
empty = ''
|
178
|
+
empty.force_encoding encoding if encoding
|
179
|
+
text.gsub(/^\s+$/, empty)
|
166
180
|
end
|
167
181
|
|
168
182
|
##
|
data/test/test_rdoc_encoding.rb
CHANGED
@@ -49,6 +49,26 @@ class TestRDocEncoding < MiniTest::Unit::TestCase
|
|
49
49
|
assert_equal "hi \u00e9verybody", contents.sub("\r", '')
|
50
50
|
end
|
51
51
|
|
52
|
+
def test_class_read_file_encoding_fail
|
53
|
+
skip "Encoding not implemented" unless Object.const_defined? :Encoding
|
54
|
+
|
55
|
+
@tempfile.write "# coding: utf-8\n\317\200" # pi
|
56
|
+
@tempfile.flush
|
57
|
+
|
58
|
+
# FIXME 1.9 fix on windoze
|
59
|
+
expected.gsub!("\n", "\r\n") if RUBY_VERSION =~ /^1.9/ && RUBY_PLATFORM =~ /mswin|mingw/
|
60
|
+
|
61
|
+
contents = :junk
|
62
|
+
|
63
|
+
_, err = capture_io do
|
64
|
+
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::US_ASCII
|
65
|
+
end
|
66
|
+
|
67
|
+
assert_nil contents
|
68
|
+
|
69
|
+
assert_match %r%^unable to convert%, err
|
70
|
+
end
|
71
|
+
|
52
72
|
def test_class_read_file_encoding_fancy
|
53
73
|
skip "Encoding not implemented" unless Object.const_defined? :Encoding
|
54
74
|
|
@@ -66,6 +86,21 @@ class TestRDocEncoding < MiniTest::Unit::TestCase
|
|
66
86
|
assert_equal Encoding::UTF_8, contents.encoding
|
67
87
|
end
|
68
88
|
|
89
|
+
def test_class_read_file_encoding_force_transcode
|
90
|
+
skip "Encoding not implemented" unless Object.const_defined? :Encoding
|
91
|
+
|
92
|
+
@tempfile.write "# coding: utf-8\n\317\200" # pi
|
93
|
+
@tempfile.flush
|
94
|
+
|
95
|
+
# FIXME 1.9 fix on windoze
|
96
|
+
expected.gsub!("\n", "\r\n") if RUBY_VERSION =~ /^1.9/ && RUBY_PLATFORM =~ /mswin|mingw/
|
97
|
+
|
98
|
+
contents = RDoc::Encoding.read_file @tempfile.path, Encoding::US_ASCII, true
|
99
|
+
|
100
|
+
assert_equal '?', contents
|
101
|
+
assert_equal Encoding::US_ASCII, contents.encoding
|
102
|
+
end
|
103
|
+
|
69
104
|
def test_class_read_file_encoding_guess
|
70
105
|
skip "Encoding not implemented" unless Object.const_defined? :Encoding
|
71
106
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
1
3
|
require 'tempfile'
|
2
4
|
require 'rubygems'
|
3
5
|
require 'minitest/autorun'
|
@@ -46,6 +48,30 @@ contents of a string.
|
|
46
48
|
assert_equal expected, content
|
47
49
|
end
|
48
50
|
|
51
|
+
def test_include_file_encoding_incompatible
|
52
|
+
skip "Encoding not implemented" unless Object.const_defined? :Encoding
|
53
|
+
|
54
|
+
@tempfile.write <<-INCLUDE
|
55
|
+
# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
|
56
|
+
|
57
|
+
π
|
58
|
+
INCLUDE
|
59
|
+
|
60
|
+
@tempfile.flush
|
61
|
+
@tempfile.rewind
|
62
|
+
|
63
|
+
content = @pp.include_file @file_name, '', Encoding::US_ASCII
|
64
|
+
|
65
|
+
expected = "?\n"
|
66
|
+
|
67
|
+
# FIXME 1.9 fix on windoze
|
68
|
+
# preprocessor uses binread, so line endings are \r\n
|
69
|
+
expected.gsub!("\n", "\r\n") if
|
70
|
+
RUBY_VERSION =~ /^1.9/ && RUBY_PLATFORM =~ /mswin|mingw/
|
71
|
+
|
72
|
+
assert_equal expected, content
|
73
|
+
end
|
74
|
+
|
49
75
|
def test_handle
|
50
76
|
text = "# :x: y\n"
|
51
77
|
out = @pp.handle text
|
data/test/test_rdoc_text.rb
CHANGED
@@ -55,6 +55,18 @@ class TestRDocText < MiniTest::Unit::TestCase
|
|
55
55
|
expand_tabs(".\t\t."), 'dot tab tab dot')
|
56
56
|
end
|
57
57
|
|
58
|
+
def test_expand_tabs_encoding
|
59
|
+
skip "Encoding not implemented" unless Object.const_defined? :Encoding
|
60
|
+
|
61
|
+
inn = "hello\ns\tdave"
|
62
|
+
inn.force_encoding Encoding::BINARY
|
63
|
+
|
64
|
+
out = expand_tabs inn
|
65
|
+
|
66
|
+
assert_equal "hello\ns dave", out
|
67
|
+
assert_equal Encoding::BINARY, out.encoding
|
68
|
+
end
|
69
|
+
|
58
70
|
def test_flush_left
|
59
71
|
text = <<-TEXT
|
60
72
|
|
@@ -73,6 +85,31 @@ The comments associated with
|
|
73
85
|
assert_equal expected, flush_left(text)
|
74
86
|
end
|
75
87
|
|
88
|
+
def test_flush_left_encoding
|
89
|
+
skip "Encoding not implemented" unless Object.const_defined? :Encoding
|
90
|
+
|
91
|
+
text = <<-TEXT
|
92
|
+
|
93
|
+
we don't worry too much.
|
94
|
+
|
95
|
+
The comments associated with
|
96
|
+
TEXT
|
97
|
+
|
98
|
+
text.force_encoding Encoding::US_ASCII
|
99
|
+
|
100
|
+
expected = <<-EXPECTED
|
101
|
+
|
102
|
+
we don't worry too much.
|
103
|
+
|
104
|
+
The comments associated with
|
105
|
+
EXPECTED
|
106
|
+
|
107
|
+
result = flush_left text
|
108
|
+
|
109
|
+
assert_equal expected, result
|
110
|
+
assert_equal Encoding::US_ASCII, result.encoding
|
111
|
+
end
|
112
|
+
|
76
113
|
def test_markup
|
77
114
|
def formatter() RDoc::Markup::ToHtml.new end
|
78
115
|
|
@@ -223,8 +260,36 @@ The comments associated with
|
|
223
260
|
The comments associated with
|
224
261
|
EXPECTED
|
225
262
|
|
226
|
-
|
227
|
-
|
263
|
+
result = strip_stars text
|
264
|
+
|
265
|
+
assert_equal expected, result
|
266
|
+
assert_equal Encoding::CP852, result.encoding
|
267
|
+
end
|
268
|
+
|
269
|
+
def test_strip_stars_encoding2
|
270
|
+
skip "Encoding not implemented" unless Object.const_defined? :Encoding
|
271
|
+
|
272
|
+
text = <<-TEXT
|
273
|
+
/*
|
274
|
+
* * we don't worry too much.
|
275
|
+
*
|
276
|
+
* The comments associated with
|
277
|
+
*/
|
278
|
+
TEXT
|
279
|
+
|
280
|
+
text.force_encoding Encoding::BINARY
|
281
|
+
|
282
|
+
expected = <<-EXPECTED
|
283
|
+
|
284
|
+
* we don't worry too much.
|
285
|
+
|
286
|
+
The comments associated with
|
287
|
+
EXPECTED
|
288
|
+
|
289
|
+
result = strip_stars text
|
290
|
+
|
291
|
+
assert_equal expected, result
|
292
|
+
assert_equal Encoding::BINARY, result.encoding
|
228
293
|
end
|
229
294
|
|
230
295
|
def test_to_html_apostrophe
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 3.5.
|
9
|
+
- 3
|
10
|
+
version: 3.5.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eric Hodel
|
@@ -39,7 +39,7 @@ cert_chain:
|
|
39
39
|
x52qPcexcYZR7w==
|
40
40
|
-----END CERTIFICATE-----
|
41
41
|
|
42
|
-
date: 2011-02-
|
42
|
+
date: 2011-02-06 00:00:00 -08:00
|
43
43
|
default_executable:
|
44
44
|
dependencies:
|
45
45
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
Binary file
|