rdoc 2.5.11 → 3.0

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.

Files changed (113) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.document +1 -0
  3. data/History.txt +95 -0
  4. data/Manifest.txt +13 -4
  5. data/README.txt +9 -3
  6. data/Rakefile +1 -1
  7. data/lib/rdoc.rb +15 -298
  8. data/lib/rdoc/alias.rb +65 -16
  9. data/lib/rdoc/any_method.rb +27 -150
  10. data/lib/rdoc/attr.rb +36 -115
  11. data/lib/rdoc/class_module.rb +236 -22
  12. data/lib/rdoc/code_object.rb +76 -31
  13. data/lib/rdoc/constant.rb +32 -4
  14. data/lib/rdoc/context.rb +494 -222
  15. data/lib/rdoc/encoding.rb +79 -0
  16. data/lib/rdoc/erbio.rb +37 -0
  17. data/lib/rdoc/gauntlet.rb +9 -5
  18. data/lib/rdoc/generator.rb +33 -1
  19. data/lib/rdoc/generator/darkfish.rb +284 -375
  20. data/lib/rdoc/generator/markup.rb +72 -36
  21. data/lib/rdoc/generator/ri.rb +4 -4
  22. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +267 -274
  23. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +91 -91
  24. data/lib/rdoc/generator/template/darkfish/index.rhtml +45 -45
  25. data/lib/rdoc/generator/template/darkfish/rdoc.css +298 -298
  26. data/lib/rdoc/include.rb +40 -1
  27. data/lib/rdoc/known_classes.rb +1 -0
  28. data/lib/rdoc/markup.rb +467 -2
  29. data/lib/rdoc/markup/attribute_manager.rb +24 -6
  30. data/lib/rdoc/markup/blank_line.rb +11 -3
  31. data/lib/rdoc/markup/document.rb +6 -0
  32. data/lib/rdoc/markup/formatter.rb +10 -0
  33. data/lib/rdoc/markup/formatter_test_case.rb +339 -3
  34. data/lib/rdoc/markup/heading.rb +3 -0
  35. data/lib/rdoc/markup/inline.rb +11 -1
  36. data/lib/rdoc/markup/list.rb +3 -0
  37. data/lib/rdoc/markup/list_item.rb +3 -0
  38. data/lib/rdoc/markup/paragraph.rb +3 -0
  39. data/lib/rdoc/markup/parser.rb +191 -237
  40. data/lib/rdoc/markup/{preprocess.rb → pre_process.rb} +50 -29
  41. data/lib/rdoc/markup/raw.rb +4 -0
  42. data/lib/rdoc/markup/rule.rb +3 -0
  43. data/lib/rdoc/markup/text_formatter_test_case.rb +116 -0
  44. data/lib/rdoc/markup/to_ansi.rb +14 -2
  45. data/lib/rdoc/markup/to_bs.rb +8 -2
  46. data/lib/rdoc/markup/to_html.rb +84 -91
  47. data/lib/rdoc/markup/to_html_crossref.rb +77 -26
  48. data/lib/rdoc/markup/to_rdoc.rb +94 -49
  49. data/lib/rdoc/markup/to_test.rb +9 -1
  50. data/lib/rdoc/markup/verbatim.rb +6 -3
  51. data/lib/rdoc/method_attr.rb +353 -0
  52. data/lib/rdoc/normal_class.rb +11 -2
  53. data/lib/rdoc/normal_module.rb +0 -5
  54. data/lib/rdoc/options.rb +373 -82
  55. data/lib/rdoc/parser.rb +59 -23
  56. data/lib/rdoc/parser/c.rb +224 -86
  57. data/lib/rdoc/parser/ruby.rb +219 -111
  58. data/lib/rdoc/parser/ruby_tools.rb +4 -1
  59. data/lib/rdoc/parser/simple.rb +9 -4
  60. data/lib/rdoc/rdoc.rb +68 -28
  61. data/lib/rdoc/require.rb +21 -0
  62. data/lib/rdoc/ri/driver.rb +20 -10
  63. data/lib/rdoc/ri/paths.rb +2 -2
  64. data/lib/rdoc/ri/store.rb +22 -5
  65. data/lib/rdoc/ruby_lex.rb +11 -12
  66. data/lib/rdoc/ruby_token.rb +2 -2
  67. data/lib/rdoc/single_class.rb +2 -1
  68. data/lib/rdoc/stats.rb +202 -162
  69. data/lib/rdoc/stats/normal.rb +51 -0
  70. data/lib/rdoc/stats/quiet.rb +59 -0
  71. data/lib/rdoc/stats/verbose.rb +45 -0
  72. data/lib/rdoc/text.rb +133 -4
  73. data/lib/rdoc/{tokenstream.rb → token_stream.rb} +0 -2
  74. data/lib/rdoc/top_level.rb +230 -39
  75. data/test/test_attribute_manager.rb +58 -7
  76. data/test/test_rdoc_alias.rb +13 -0
  77. data/test/test_rdoc_any_method.rb +43 -2
  78. data/test/test_rdoc_attr.rb +15 -8
  79. data/test/test_rdoc_class_module.rb +133 -0
  80. data/test/test_rdoc_code_object.rb +62 -5
  81. data/test/test_rdoc_context.rb +72 -26
  82. data/test/test_rdoc_encoding.rb +145 -0
  83. data/test/test_rdoc_generator_darkfish.rb +119 -0
  84. data/test/test_rdoc_generator_ri.rb +22 -2
  85. data/test/test_rdoc_include.rb +79 -0
  86. data/test/test_rdoc_markup_attribute_manager.rb +4 -4
  87. data/test/test_rdoc_markup_parser.rb +134 -95
  88. data/test/test_rdoc_markup_pre_process.rb +7 -2
  89. data/test/test_rdoc_markup_to_ansi.rb +43 -153
  90. data/test/test_rdoc_markup_to_bs.rb +42 -156
  91. data/test/test_rdoc_markup_to_html.rb +130 -58
  92. data/test/test_rdoc_markup_to_html_crossref.rb +10 -10
  93. data/test/test_rdoc_markup_to_rdoc.rb +40 -151
  94. data/test/test_rdoc_method_attr.rb +122 -0
  95. data/test/test_rdoc_normal_class.rb +1 -1
  96. data/test/test_rdoc_normal_module.rb +6 -1
  97. data/test/test_rdoc_options.rb +237 -12
  98. data/test/test_rdoc_parser.rb +3 -22
  99. data/test/test_rdoc_parser_c.rb +203 -2
  100. data/test/test_rdoc_parser_ruby.rb +403 -89
  101. data/test/test_rdoc_parser_simple.rb +25 -1
  102. data/test/test_rdoc_rdoc.rb +44 -32
  103. data/test/test_rdoc_ri_driver.rb +29 -24
  104. data/test/test_rdoc_ri_store.rb +46 -3
  105. data/test/test_rdoc_task.rb +1 -1
  106. data/test/test_rdoc_text.rb +102 -8
  107. data/test/test_rdoc_top_level.rb +13 -4
  108. data/test/xref_data.rb +8 -0
  109. data/test/xref_test_case.rb +6 -0
  110. metadata +29 -19
  111. metadata.gz.sig +0 -0
  112. data/lib/rdoc/parser/perl.rb +0 -165
  113. data/test/test_rdoc_parser_perl.rb +0 -73
@@ -41,7 +41,6 @@ contents of a string.
41
41
  parser.scan
42
42
 
43
43
  expected = <<-TEXT.strip
44
-
45
44
  Regular expressions (<i>regexp</i>s) are patterns which describe the
46
45
  contents of a string.
47
46
  TEXT
@@ -49,6 +48,31 @@ contents of a string.
49
48
  assert_equal expected, @top_level.comment
50
49
  end
51
50
 
51
+ # RDoc stops processing comments if it finds a comment line CONTAINING
52
+ # '<tt>#--</tt>'. This can be used to separate external from internal
53
+ # comments, or to stop a comment being associated with a method,
54
+ # class, or module. Commenting CAN be turned back on with
55
+ # a line that STARTS '<tt>#++</tt>'.
56
+ #
57
+ # I've seen guys that comment their code like this:
58
+ # # This method....
59
+ # #-----------------
60
+ # def method
61
+ #
62
+ # => either we do it only in ruby code, or we require the leading #
63
+ # (to avoid conflict with rules).
64
+ #
65
+ # TODO: require the leading #, to provide the feature in simple text files.
66
+ # Note: in ruby & C code, we require '#--' & '#++' or '*--' & '*++',
67
+ # to allow rules:
68
+ #
69
+ # # this is a comment
70
+ # #---
71
+ # # private text
72
+ # #+++
73
+ # # this is a rule:
74
+ # # ---
75
+
52
76
  def test_remove_private_comments
53
77
  parser = util_parser ''
54
78
  text = "foo\n\n--\nbar\n++\n\nbaz\n"
@@ -1,13 +1,20 @@
1
- require 'tempfile'
2
- require 'tmpdir'
3
1
  require 'rubygems'
4
2
  require 'minitest/autorun'
5
3
  require 'rdoc/rdoc'
6
4
 
5
+ require 'fileutils'
6
+ require 'tempfile'
7
+ require 'tmpdir'
8
+
7
9
  class TestRDocRDoc < MiniTest::Unit::TestCase
8
10
 
9
11
  def setup
10
12
  @rdoc = RDoc::RDoc.new
13
+ @rdoc.options = RDoc::Options.new
14
+
15
+ @stats = RDoc::Stats.new 0, 0
16
+ @rdoc.instance_variable_set :@stats, @stats
17
+
11
18
  @tempfile = Tempfile.new 'test_rdoc_rdoc'
12
19
  end
13
20
 
@@ -38,36 +45,6 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
38
45
  assert_empty files
39
46
  end
40
47
 
41
- def test_read_file_contents
42
- @tempfile.write "hi everybody"
43
- @tempfile.flush
44
-
45
- assert_equal "hi everybody", @rdoc.read_file_contents(@tempfile.path)
46
- end
47
-
48
- def test_read_file_contents_encoding
49
- skip "Encoding not implemented" unless defined? ::Encoding
50
-
51
- @tempfile.write "# coding: utf-8\nhi everybody"
52
- @tempfile.flush
53
-
54
- contents = @rdoc.read_file_contents @tempfile.path
55
- assert_equal "# coding: utf-8\nhi everybody", contents
56
- assert_equal Encoding::UTF_8, contents.encoding
57
- end
58
-
59
- def test_read_file_contents_encoding_fancy
60
- skip "Encoding not implemented" unless defined? ::Encoding
61
-
62
- @tempfile.write "# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody"
63
- @tempfile.flush
64
-
65
- contents = @rdoc.read_file_contents @tempfile.path
66
- assert_equal("# -*- coding: utf-8; fill-column: 74 -*-\nhi everybody",
67
- contents)
68
- assert_equal Encoding::UTF_8, contents.encoding
69
- end
70
-
71
48
  def test_remove_unparsable
72
49
  file_list = %w[
73
50
  blah.class
@@ -95,6 +72,20 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
95
72
  }
96
73
  end
97
74
 
75
+ def test_setup_output_dir_dry_run
76
+ skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir
77
+
78
+ @rdoc.options.dry_run = true
79
+
80
+ Dir.mktmpdir do |d|
81
+ path = File.join d, 'testdir'
82
+
83
+ @rdoc.setup_output_dir path, false
84
+
85
+ refute File.exist? path
86
+ end
87
+ end
88
+
98
89
  def test_setup_output_dir_exists
99
90
  skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir
100
91
 
@@ -148,5 +139,26 @@ class TestRDocRDoc < MiniTest::Unit::TestCase
148
139
  end
149
140
  end
150
141
 
142
+ def test_update_output_dir
143
+ skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir
144
+
145
+ Dir.mktmpdir do |d|
146
+ @rdoc.update_output_dir d, Time.now, {}
147
+
148
+ assert File.exist? "#{d}/created.rid"
149
+ end
150
+ end
151
+
152
+ def test_update_output_dir_dry_run
153
+ skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir
154
+
155
+ Dir.mktmpdir do |d|
156
+ @rdoc.options.dry_run = true
157
+ @rdoc.update_output_dir d, Time.now, {}
158
+
159
+ refute File.exist? "#{d}/created.rid"
160
+ end
161
+ end
162
+
151
163
  end
152
164
 
@@ -53,7 +53,7 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
53
53
  def test_self_dump
54
54
  util_store
55
55
 
56
- out, err = capture_io do
56
+ out, = capture_io do
57
57
  RDoc::RI::Driver.dump @store.cache_path
58
58
  end
59
59
 
@@ -83,8 +83,8 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
83
83
  expected = @RM::Document.new(
84
84
  @RM::Rule.new(1),
85
85
  @RM::Paragraph.new('Also found in:'),
86
- @RM::Verbatim.new(' ', 'ruby core', "\n",
87
- ' ', '~/.ri', "\n"))
86
+ @RM::Verbatim.new("ruby core\n",
87
+ "~/.ri\n"))
88
88
 
89
89
  assert_equal expected, out
90
90
  end
@@ -143,7 +143,7 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
143
143
  @RM::BlankLine.new,
144
144
  @RM::Paragraph.new("Include thingy"),
145
145
  @RM::BlankLine.new,
146
- @RM::Verbatim.new(' ', 'Enumerable', "\n"))
146
+ @RM::Verbatim.new("Enumerable\n"))
147
147
 
148
148
  assert_equal expected, out
149
149
  end
@@ -163,8 +163,8 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
163
163
  @RM::Rule.new(1),
164
164
  @RM::Heading.new(1, "Includes:"),
165
165
  @RM::Paragraph.new("(from #{@store.friendly_path})"),
166
- @RM::Verbatim.new(' ', 'Inc', "\n",
167
- ' ', 'Enumerable', "\n"))
166
+ @RM::Verbatim.new("Inc\n",
167
+ "Enumerable\n"))
168
168
 
169
169
  assert_equal expected, out
170
170
  end
@@ -195,7 +195,7 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
195
195
  expected = @RM::Document.new(
196
196
  @RM::Heading.new(1, 'Class methods:'),
197
197
  @RM::BlankLine.new,
198
- @RM::Verbatim.new(' ', 'new'),
198
+ @RM::Verbatim.new('new'),
199
199
  @RM::BlankLine.new)
200
200
 
201
201
  assert_equal expected, out
@@ -285,7 +285,7 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
285
285
  doc = @RM::Document.new(
286
286
  @RM::Paragraph.new('hi'))
287
287
 
288
- out, err = capture_io do
288
+ out, = capture_io do
289
289
  @driver.display doc
290
290
  end
291
291
 
@@ -295,12 +295,12 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
295
295
  def test_display_class
296
296
  util_store
297
297
 
298
- out, err = capture_io do
298
+ out, = capture_io do
299
299
  @driver.display_class 'Foo::Bar'
300
300
  end
301
301
 
302
302
  assert_match %r%^= Foo::Bar%, out
303
- assert_match %r%^\(from%, out # )
303
+ assert_match %r%^\(from%, out
304
304
 
305
305
  assert_match %r%^= Class methods:%, out
306
306
  assert_match %r%^ new%, out
@@ -315,7 +315,7 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
315
315
  def test_display_class_ambiguous
316
316
  util_multi_store
317
317
 
318
- out, err = capture_io do
318
+ out, = capture_io do
319
319
  @driver.display_class 'Ambiguous'
320
320
  end
321
321
 
@@ -325,7 +325,7 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
325
325
  def test_display_class_multi_no_doc
326
326
  util_multi_store
327
327
 
328
- out, err = capture_io do
328
+ out, = capture_io do
329
329
  @driver.display_class 'Foo::Baz'
330
330
  end
331
331
 
@@ -339,7 +339,7 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
339
339
  def test_display_class_superclass
340
340
  util_multi_store
341
341
 
342
- out, err = capture_io do
342
+ out, = capture_io do
343
343
  @driver.display_class 'Bar'
344
344
  end
345
345
 
@@ -349,7 +349,7 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
349
349
  def test_display_class_module
350
350
  util_store
351
351
 
352
- out, err = capture_io do
352
+ out, = capture_io do
353
353
  @driver.display_class 'Inc'
354
354
  end
355
355
 
@@ -359,7 +359,7 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
359
359
  def test_display_method
360
360
  util_store
361
361
 
362
- out, err = capture_io do
362
+ out, = capture_io do
363
363
  @driver.display_method 'Foo::Bar#blah'
364
364
  end
365
365
 
@@ -371,7 +371,7 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
371
371
  def test_display_method_attribute
372
372
  util_store
373
373
 
374
- out, err = capture_io do
374
+ out, = capture_io do
375
375
  @driver.display_method 'Foo::Bar#attr'
376
376
  end
377
377
 
@@ -382,7 +382,7 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
382
382
  def test_display_method_inherited
383
383
  util_multi_store
384
384
 
385
- out, err = capture_io do
385
+ out, = capture_io do
386
386
  @driver.display_method 'Bar#inherit'
387
387
  end
388
388
 
@@ -393,7 +393,7 @@ class TestRDocRIDriver < MiniTest::Unit::TestCase
393
393
  def test_display_name_not_found_class
394
394
  util_store
395
395
 
396
- out, err = capture_io do
396
+ out, = capture_io do
397
397
  assert_equal false, @driver.display_name('Foo::B')
398
398
  end
399
399
 
@@ -410,7 +410,7 @@ Foo::Baz
410
410
  def test_display_name_not_found_method
411
411
  util_store
412
412
 
413
- out, err = capture_io do
413
+ out, = capture_io do
414
414
  assert_equal false, @driver.display_name('Foo::Bar#b')
415
415
  end
416
416
 
@@ -427,7 +427,7 @@ Foo::Bar#bother
427
427
  def test_display_method_params
428
428
  util_store
429
429
 
430
- out, err = capture_io do
430
+ out, = capture_io do
431
431
  @driver.display_method 'Foo::Bar#bother'
432
432
  end
433
433
 
@@ -496,17 +496,22 @@ Foo::Bar#bother
496
496
  end
497
497
 
498
498
  def test_formatter
499
+ tty = Object.new
500
+ def tty.tty?() true; end
501
+
499
502
  driver = RDoc::RI::Driver.new
500
503
 
501
- assert_instance_of @RM::ToAnsi, driver.formatter
504
+ assert_instance_of @RM::ToAnsi, driver.formatter(tty)
505
+
506
+ assert_instance_of @RM::ToBs, driver.formatter(StringIO.new)
502
507
 
503
508
  driver.instance_variable_set :@paging, true
504
509
 
505
- assert_instance_of @RM::ToBs, driver.formatter
510
+ assert_instance_of @RM::ToBs, driver.formatter(StringIO.new)
506
511
 
507
512
  driver.instance_variable_set :@formatter_klass, @RM::ToHtml
508
513
 
509
- assert_instance_of @RM::ToHtml, driver.formatter
514
+ assert_instance_of @RM::ToHtml, driver.formatter(tty)
510
515
  end
511
516
 
512
517
  def test_in_path_eh
@@ -531,7 +536,7 @@ Foo::Bar#bother
531
536
  def test_list_known_classes
532
537
  util_store
533
538
 
534
- out, err = capture_io do
539
+ out, = capture_io do
535
540
  @driver.list_known_classes
536
541
  end
537
542
 
@@ -65,6 +65,10 @@ class TestRDocRIStore < MiniTest::Unit::TestCase
65
65
  assert File.file?(path), "#{path} is not a file"
66
66
  end
67
67
 
68
+ def refute_file path
69
+ refute File.exist?(path), "#{path} exists"
70
+ end
71
+
68
72
  def test_attributes
69
73
  @s.cache[:attributes]['Object'] = %w[attr]
70
74
 
@@ -94,6 +98,14 @@ class TestRDocRIStore < MiniTest::Unit::TestCase
94
98
  @s.class_path('Object::SubClass')
95
99
  end
96
100
 
101
+ def test_dry_run
102
+ refute @s.dry_run
103
+
104
+ @s.dry_run = true
105
+
106
+ assert @s.dry_run
107
+ end
108
+
97
109
  def test_friendly_path
98
110
  @s.path = @tmpdir
99
111
  @s.type = nil
@@ -198,7 +210,7 @@ class TestRDocRIStore < MiniTest::Unit::TestCase
198
210
  :instance_methods => { 'Object' => %w[method] },
199
211
  :modules => %w[Object Object::SubClass],
200
212
  :ancestors => {
201
- 'Object' => %w[Object],
213
+ 'Object' => %w[],
202
214
  'Object::SubClass' => %w[Incl Object],
203
215
  },
204
216
  }
@@ -210,6 +222,19 @@ class TestRDocRIStore < MiniTest::Unit::TestCase
210
222
  end
211
223
  end
212
224
 
225
+ def test_save_cache_dry_run
226
+ @s.dry_run = true
227
+
228
+ @s.save_class @klass
229
+ @s.save_method @klass, @meth
230
+ @s.save_method @klass, @cmeth
231
+ @s.save_class @nest_klass
232
+
233
+ @s.save_cache
234
+
235
+ refute_file File.join(@tmpdir, 'cache.ri')
236
+ end
237
+
213
238
  def test_save_cache_duplicate_methods
214
239
  @s.save_method @klass, @meth
215
240
  @s.save_method @klass, @meth
@@ -226,7 +251,7 @@ class TestRDocRIStore < MiniTest::Unit::TestCase
226
251
  assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
227
252
 
228
253
  assert_cache({}, {}, { 'Object' => ['attr_accessor attr'] }, %w[Object],
229
- 'Object' => %w[Object])
254
+ 'Object' => %w[])
230
255
 
231
256
  assert_equal @klass, @s.load_class('Object')
232
257
  end
@@ -245,6 +270,15 @@ class TestRDocRIStore < MiniTest::Unit::TestCase
245
270
  assert_equal @klass, @s.load_class('Object')
246
271
  end
247
272
 
273
+ def test_save_class_dry_run
274
+ @s.dry_run = true
275
+
276
+ @s.save_class @klass
277
+
278
+ refute_file File.join(@tmpdir, 'Object')
279
+ refute_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
280
+ end
281
+
248
282
  def test_save_class_merge
249
283
  @s.save_class @klass
250
284
 
@@ -270,7 +304,7 @@ class TestRDocRIStore < MiniTest::Unit::TestCase
270
304
  assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
271
305
 
272
306
  assert_cache({}, {}, { 'Object' => ['attr_accessor attr'] }, %w[Object],
273
- 'Object' => %w[Object])
307
+ 'Object' => %w[])
274
308
 
275
309
  assert_equal @klass, @s.load_class('Object')
276
310
  end
@@ -296,6 +330,15 @@ class TestRDocRIStore < MiniTest::Unit::TestCase
296
330
  assert_equal @meth, @s.load_method('Object', '#method')
297
331
  end
298
332
 
333
+ def test_save_method_dry_run
334
+ @s.dry_run = true
335
+
336
+ @s.save_method @klass, @meth
337
+
338
+ refute_file File.join(@tmpdir, 'Object')
339
+ refute_file File.join(@tmpdir, 'Object', 'method-i.ri')
340
+ end
341
+
299
342
  def test_save_method_nested
300
343
  @s.save_method @nest_klass, @nest_meth
301
344
 
@@ -42,7 +42,7 @@ class TestRDocTask < MiniTest::Unit::TestCase
42
42
  end
43
43
 
44
44
  def test_tasks_creation_with_custom_name_hash_will_use_default_if_an_option_isnt_given
45
- rd = RDoc::Task.new(:clobber_rdoc => "rdoc:clean")
45
+ RDoc::Task.new(:clobber_rdoc => "rdoc:clean")
46
46
  assert Rake::Task[:rdoc]
47
47
  assert Rake::Task[:"rdoc:clean"]
48
48
  assert Rake::Task[:rerdoc]
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require 'rubygems'
2
4
  require 'minitest/autorun'
3
5
  require 'rdoc'
@@ -9,6 +11,15 @@ class TestRDocText < MiniTest::Unit::TestCase
9
11
 
10
12
  include RDoc::Text
11
13
 
14
+ def test_self_encode_fallback
15
+ skip "Encoding not implemented" unless Object.const_defined? :Encoding
16
+
17
+ assert_equal '…',
18
+ RDoc::Text::encode_fallback('…', Encoding::UTF_8, '...')
19
+ assert_equal '...',
20
+ RDoc::Text::encode_fallback('…', Encoding::US_ASCII, '...')
21
+ end
22
+
12
23
  def test_expand_tabs
13
24
  assert_equal("hello\n dave",
14
25
  expand_tabs("hello\n dave"), 'spaces')
@@ -46,9 +57,9 @@ class TestRDocText < MiniTest::Unit::TestCase
46
57
 
47
58
  def test_flush_left
48
59
  text = <<-TEXT
49
-
60
+
50
61
  we don't worry too much.
51
-
62
+
52
63
  The comments associated with
53
64
  TEXT
54
65
 
@@ -65,7 +76,7 @@ The comments associated with
65
76
  def test_markup
66
77
  def formatter() RDoc::Markup::ToHtml.new end
67
78
 
68
- assert_equal "<p>\nhi\n</p>\n", markup('hi')
79
+ assert_equal "<p>hi</p>", markup('hi').gsub("\n", '')
69
80
  end
70
81
 
71
82
  def test_normalize_comment
@@ -114,9 +125,9 @@ The comments associated with
114
125
  TEXT
115
126
 
116
127
  expected = <<-EXPECTED
117
-
128
+
118
129
  we don't worry too much.
119
-
130
+
120
131
  The comments associated with
121
132
  EXPECTED
122
133
 
@@ -143,15 +154,98 @@ The comments associated with
143
154
  TEXT
144
155
 
145
156
  expected = <<-EXPECTED
146
-
157
+
147
158
  * we don't worry too much.
148
-
159
+
149
160
  The comments associated with
150
-
151
161
  EXPECTED
152
162
 
153
163
  assert_equal expected, strip_stars(text)
154
164
  end
155
165
 
166
+ def test_to_html_apostrophe
167
+ assert_equal '‘a', to_html("'a")
168
+ assert_equal 'a’', to_html("a'")
169
+
170
+ assert_equal '‘a’ ‘', to_html("'a' '")
171
+ end
172
+
173
+ def test_to_html_backslash
174
+ assert_equal 'S', to_html('\\S')
175
+ end
176
+
177
+ def test_to_html_copyright
178
+ assert_equal '©', to_html('(c)')
179
+ end
180
+
181
+ def test_to_html_dash
182
+ assert_equal '-', to_html('-')
183
+ assert_equal '–', to_html('--')
184
+ assert_equal '—', to_html('---')
185
+ assert_equal '—-', to_html('----')
186
+ end
187
+
188
+ def test_to_html_double_backtick
189
+ assert_equal '“a', to_html('``a')
190
+ assert_equal '“a“', to_html('``a``')
191
+ end
192
+
193
+ def test_to_html_double_quote
194
+ assert_equal '“a', to_html('"a')
195
+ assert_equal '“a”', to_html('"a"')
196
+ end
197
+
198
+ def test_to_html_double_quote_quot
199
+ assert_equal '“a', to_html('&quot;a')
200
+ assert_equal '“a”', to_html('&quot;a&quot;')
201
+ end
202
+
203
+ def test_to_html_double_tick
204
+ assert_equal '”a', to_html("''a")
205
+ assert_equal '”a”', to_html("''a''")
206
+ end
207
+
208
+ def test_to_html_ellipsis
209
+ assert_equal '..', to_html('..')
210
+ assert_equal '…', to_html('...')
211
+ assert_equal '.…', to_html('....')
212
+ end
213
+
214
+ def test_to_html_encoding
215
+ skip "Encoding not implemented" unless Object.const_defined? :Encoding
216
+
217
+ s = '...(c)'.encode Encoding::Shift_JIS
218
+
219
+ html = to_html s
220
+
221
+ assert_equal Encoding::Shift_JIS, html.encoding
222
+
223
+ expected = '…(c)'.encode Encoding::Shift_JIS
224
+
225
+ assert_equal expected, html
226
+ end
227
+
228
+ def test_to_html_html_tag
229
+ assert_equal '<a href="http://example">hi’s</a>',
230
+ to_html('<a href="http://example">hi\'s</a>')
231
+ end
232
+
233
+ def test_to_html_registered_trademark
234
+ assert_equal '®', to_html('(r)')
235
+ end
236
+
237
+ def test_to_html_tt_tag
238
+ assert_equal '<tt>hi\'s</tt>', to_html('<tt>hi\'s</tt>')
239
+ assert_equal '<tt>hi\\\'s</tt>', to_html('<tt>hi\\\\\'s</tt>')
240
+ end
241
+
242
+ def test_to_html_tt_tag_mismatch
243
+ _, err = capture_io do
244
+ assert_equal '<tt>hi', to_html('<tt>hi')
245
+ end
246
+
247
+ assert_equal "mismatched <tt> tag\n", err
248
+ end
249
+
156
250
  end
157
251