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.

Files changed (139) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +3 -1
  3. data/History.txt +68 -0
  4. data/LICENSE.txt +57 -0
  5. data/Manifest.txt +37 -19
  6. data/README.txt +2 -12
  7. data/Rakefile +12 -12
  8. data/bin/rdoc +4 -4
  9. data/lib/rdoc.rb +32 -9
  10. data/lib/rdoc/alias.rb +2 -2
  11. data/lib/rdoc/any_method.rb +108 -16
  12. data/lib/rdoc/attr.rb +87 -1
  13. data/lib/rdoc/class_module.rb +131 -5
  14. data/lib/rdoc/code_object.rb +28 -5
  15. data/lib/rdoc/constant.rb +22 -0
  16. data/lib/rdoc/context.rb +80 -37
  17. data/lib/rdoc/gauntlet.rb +48 -0
  18. data/lib/rdoc/generator/darkfish.rb +25 -23
  19. data/lib/rdoc/generator/markup.rb +6 -29
  20. data/lib/rdoc/generator/ri.rb +39 -189
  21. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +17 -1
  22. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +10 -0
  23. data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  24. data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  25. data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  26. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  27. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  28. data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  29. data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  30. data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  31. data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  32. data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  33. data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  34. data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  35. data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  36. data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  37. data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  38. data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  39. data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  40. data/lib/rdoc/generator/template/darkfish/index.rhtml +2 -2
  41. data/lib/rdoc/generator/template/darkfish/rdoc.css +38 -33
  42. data/lib/rdoc/include.rb +22 -0
  43. data/lib/rdoc/markup.rb +10 -262
  44. data/lib/rdoc/markup/attribute_manager.rb +57 -50
  45. data/lib/rdoc/markup/blank_line.rb +19 -0
  46. data/lib/rdoc/markup/document.rb +72 -0
  47. data/lib/rdoc/markup/formatter.rb +118 -0
  48. data/lib/rdoc/markup/formatter_test_case.rb +341 -0
  49. data/lib/rdoc/markup/heading.rb +17 -0
  50. data/lib/rdoc/markup/inline.rb +6 -5
  51. data/lib/rdoc/markup/list.rb +78 -0
  52. data/lib/rdoc/markup/list_item.rb +83 -0
  53. data/lib/rdoc/markup/paragraph.rb +66 -0
  54. data/lib/rdoc/markup/parser.rb +528 -0
  55. data/lib/rdoc/markup/rule.rb +17 -0
  56. data/lib/rdoc/markup/to_ansi.rb +72 -0
  57. data/lib/rdoc/markup/to_bs.rb +74 -0
  58. data/lib/rdoc/markup/to_html.rb +106 -172
  59. data/lib/rdoc/markup/to_html_crossref.rb +10 -4
  60. data/lib/rdoc/markup/to_rdoc.rb +243 -0
  61. data/lib/rdoc/markup/to_test.rb +27 -16
  62. data/lib/rdoc/markup/verbatim.rb +42 -0
  63. data/lib/rdoc/normal_class.rb +38 -1
  64. data/lib/rdoc/normal_module.rb +38 -8
  65. data/lib/rdoc/options.rb +39 -151
  66. data/lib/rdoc/parser.rb +36 -18
  67. data/lib/rdoc/parser/c.rb +102 -109
  68. data/lib/rdoc/parser/ruby.rb +359 -1662
  69. data/lib/rdoc/parser/ruby_tools.rb +157 -0
  70. data/lib/rdoc/parser/simple.rb +0 -2
  71. data/lib/rdoc/rdoc.rb +142 -82
  72. data/lib/rdoc/ri.rb +10 -0
  73. data/lib/rdoc/ri/driver.rb +674 -444
  74. data/lib/rdoc/ri/formatter.rb +2 -651
  75. data/lib/rdoc/ri/paths.rb +70 -45
  76. data/lib/rdoc/ri/store.rb +248 -0
  77. data/lib/rdoc/ruby_lex.rb +1284 -0
  78. data/lib/rdoc/ruby_token.rb +416 -0
  79. data/lib/rdoc/single_class.rb +5 -0
  80. data/lib/rdoc/stats.rb +152 -83
  81. data/lib/rdoc/task.rb +27 -49
  82. data/lib/rdoc/text.rb +130 -0
  83. data/lib/rdoc/tokenstream.rb +28 -9
  84. data/lib/rdoc/top_level.rb +49 -43
  85. data/test/hidden.zip.txt +1 -0
  86. data/test/test_attribute_manager.rb +9 -16
  87. data/test/test_rdoc_any_method.rb +23 -0
  88. data/test/test_rdoc_attr.rb +40 -0
  89. data/test/test_rdoc_class_module.rb +100 -0
  90. data/test/test_rdoc_code_object.rb +18 -2
  91. data/test/test_rdoc_context.rb +41 -0
  92. data/test/test_rdoc_generator_ri.rb +56 -0
  93. data/test/test_rdoc_markup.rb +21 -610
  94. data/test/test_rdoc_markup_attribute_manager.rb +14 -17
  95. data/test/test_rdoc_markup_document.rb +51 -0
  96. data/test/test_rdoc_markup_paragraph.rb +27 -0
  97. data/test/test_rdoc_markup_parser.rb +1327 -0
  98. data/test/test_rdoc_markup_to_ansi.rb +426 -0
  99. data/test/test_rdoc_markup_to_bs.rb +443 -0
  100. data/test/test_rdoc_markup_to_html.rb +183 -18
  101. data/test/test_rdoc_markup_to_html_crossref.rb +1 -3
  102. data/test/test_rdoc_markup_to_rdoc.rb +426 -0
  103. data/test/test_rdoc_normal_class.rb +17 -0
  104. data/test/test_rdoc_normal_module.rb +6 -6
  105. data/test/test_rdoc_options.rb +41 -0
  106. data/test/test_rdoc_parser.rb +66 -13
  107. data/test/test_rdoc_parser_c.rb +93 -38
  108. data/test/test_rdoc_parser_perl.rb +2 -3
  109. data/test/test_rdoc_parser_ruby.rb +291 -28
  110. data/test/test_rdoc_parser_simple.rb +48 -0
  111. data/test/test_rdoc_rdoc.rb +66 -0
  112. data/test/test_rdoc_ri_driver.rb +752 -38
  113. data/test/test_rdoc_ri_paths.rb +39 -0
  114. data/test/test_rdoc_ri_store.rb +309 -0
  115. data/test/test_rdoc_text.rb +157 -0
  116. data/test/test_rdoc_top_level.rb +35 -9
  117. data/test/xref_data.rb +9 -1
  118. data/test/xref_test_case.rb +8 -3
  119. metadata +110 -38
  120. metadata.gz.sig +0 -0
  121. data/lib/rdoc/cache.rb +0 -41
  122. data/lib/rdoc/diagram.rb +0 -340
  123. data/lib/rdoc/dot.rb +0 -249
  124. data/lib/rdoc/markup/fragments.rb +0 -377
  125. data/lib/rdoc/markup/lines.rb +0 -156
  126. data/lib/rdoc/markup/to_flow.rb +0 -211
  127. data/lib/rdoc/markup/to_latex.rb +0 -328
  128. data/lib/rdoc/markup/to_texinfo.rb +0 -73
  129. data/lib/rdoc/ri/cache.rb +0 -187
  130. data/lib/rdoc/ri/descriptions.rb +0 -156
  131. data/lib/rdoc/ri/display.rb +0 -340
  132. data/lib/rdoc/ri/reader.rb +0 -106
  133. data/lib/rdoc/ri/util.rb +0 -79
  134. data/lib/rdoc/ri/writer.rb +0 -68
  135. data/test/test_rdoc_ri_attribute_formatter.rb +0 -44
  136. data/test/test_rdoc_ri_default_display.rb +0 -302
  137. data/test/test_rdoc_ri_formatter.rb +0 -320
  138. data/test/test_rdoc_ri_html_formatter.rb +0 -141
  139. data/test/test_rdoc_ri_overstrike_formatter.rb +0 -71
@@ -0,0 +1,17 @@
1
+ require 'test/xref_test_case'
2
+
3
+ class TestRDocNormalClass < XrefTestCase
4
+
5
+ def test_ancestors_class
6
+ top_level = RDoc::TopLevel.new 'file.rb'
7
+ klass = top_level.add_class RDoc::NormalClass, 'Klass'
8
+ incl = RDoc::Include.new 'Incl', ''
9
+
10
+ sub_klass = klass.add_class RDoc::NormalClass, 'SubClass', 'Klass'
11
+ sub_klass.add_include incl
12
+
13
+ assert_equal [incl, klass], sub_klass.ancestors
14
+ end
15
+
16
+ end
17
+
@@ -8,14 +8,14 @@ class TestRDocNormalModule < XrefTestCase
8
8
  @mod = RDoc::NormalModule.new 'Mod'
9
9
  end
10
10
 
11
- def test_comment_equals
12
- @mod.comment = '# comment 1'
11
+ def test_ancestors_module
12
+ top_level = RDoc::TopLevel.new 'file.rb'
13
+ mod = top_level.add_module RDoc::NormalModule, 'Mod'
14
+ incl = RDoc::Include.new 'Incl', ''
13
15
 
14
- assert_equal '# comment 1', @mod.comment
16
+ mod.add_include incl
15
17
 
16
- @mod.comment = '# comment 2'
17
-
18
- assert_equal "# comment 1\n# ---\n# comment 2", @mod.comment
18
+ assert_equal [incl], mod.ancestors
19
19
  end
20
20
 
21
21
  def test_module_eh
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+ require 'minitest/autorun'
3
+ require 'rdoc/options'
4
+
5
+ class TestRDocOptions < MiniTest::Unit::TestCase
6
+
7
+ def setup
8
+ @options = RDoc::Options.new
9
+ end
10
+
11
+ def test_parse_ignore_invalid
12
+ out, err = capture_io do
13
+ @options.parse %w[--ignore-invalid --bogus]
14
+ end
15
+
16
+ refute_match %r%^Usage: %, err
17
+ assert_match %r%^invalid option: --bogus%, err
18
+ end
19
+
20
+ def test_parse_ignore_invalid_default
21
+ out, err = capture_io do
22
+ @options.parse %w[--bogus]
23
+ end
24
+
25
+ refute_match %r%^Usage: %, err
26
+ assert_match %r%^invalid option: --bogus%, err
27
+ end
28
+
29
+ def test_parse_ignore_invalid_no
30
+ out, err = capture_io do
31
+ assert_raises SystemExit do
32
+ @options.parse %w[--no-ignore-invalid --bogus]
33
+ end
34
+ end
35
+
36
+ assert_match %r%^Usage: %, err
37
+ assert_match %r%^invalid option: --bogus%, err
38
+ end
39
+
40
+ end
41
+
@@ -1,29 +1,82 @@
1
1
  require 'rubygems'
2
- require 'minitest/unit'
2
+ require 'minitest/autorun'
3
3
  require 'rdoc/parser'
4
4
  require 'rdoc/parser/ruby'
5
+ require 'tmpdir'
5
6
 
6
7
  class TestRDocParser < MiniTest::Unit::TestCase
7
- def test_can_parse
8
- assert_equal(RDoc::Parser.can_parse(__FILE__), RDoc::Parser::Ruby)
9
8
 
10
- readme_file_name = File.join(File.dirname(__FILE__), "..", "README.txt")
9
+ def setup
10
+ @RP = RDoc::Parser
11
+ @binary_dat = File.expand_path '../binary.dat', __FILE__
12
+ end
13
+
14
+ def test_class_binary_eh_erb
15
+ erb = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.erb"
16
+ open erb, 'wb' do |io|
17
+ io.write 'blah blah <%= stuff %> <% more stuff %>'
18
+ end
19
+
20
+ assert @RP.binary?(erb)
21
+
22
+ erb_rb = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.erb.rb"
23
+ open erb_rb, 'wb' do |io|
24
+ io.write 'blah blah <%= stuff %>'
25
+ end
26
+
27
+ refute @RP.binary?(erb_rb)
28
+ ensure
29
+ File.unlink erb
30
+ File.unlink erb_rb if erb_rb
31
+ end
32
+
33
+ def test_class_binary_eh_marshal
34
+ marshal = File.join Dir.tmpdir, "test_rdoc_parser_#{$$}.marshal"
35
+ open marshal, 'wb' do |io|
36
+ io.write Marshal.dump('')
37
+ io.write 'lots of text ' * 500
38
+ end
39
+
40
+ assert @RP.binary?(marshal)
41
+ ensure
42
+ File.unlink marshal
43
+ end
44
+
45
+ def test_class_can_parse
46
+ assert_equal @RP.can_parse(__FILE__), @RP::Ruby
47
+
48
+ readme_file_name = File.expand_path '../README.txt', __FILE__
11
49
 
12
50
  unless File.exist? readme_file_name then # HACK for tests in trunk :/
13
- readme_file_name = File.join File.dirname(__FILE__), '..', '..', 'README'
51
+ readme_file_name = File.expand_path '../../README.txt', __FILE__
14
52
  end
15
53
 
16
- assert_equal(RDoc::Parser.can_parse(readme_file_name), RDoc::Parser::Simple)
54
+ assert_equal @RP.can_parse(readme_file_name), @RP::Simple
17
55
 
18
- binary_file_name = File.join(File.dirname(__FILE__), "binary.dat")
19
- assert_equal(RDoc::Parser.can_parse(binary_file_name), nil)
56
+ assert_nil @RP.can_parse(@binary_dat)
57
+
58
+ jtest_file_name = File.expand_path '../test.ja.txt', __FILE__
59
+ assert_equal @RP::Simple, @RP.can_parse(jtest_file_name)
60
+
61
+ jtest_rdoc_file_name = File.expand_path '../test.ja.rdoc', __FILE__
62
+ assert_equal @RP::Simple, @RP.can_parse(jtest_rdoc_file_name)
63
+ end
20
64
 
21
- jtest_file_name = File.join(File.dirname(__FILE__), "test.ja.txt")
22
- assert_equal(RDoc::Parser::Simple, RDoc::Parser.can_parse(jtest_file_name))
65
+ ##
66
+ # Selenium hides a .jar file using a .txt extension.
23
67
 
24
- jtest_rdoc_file_name = File.join(File.dirname(__FILE__), "test.ja.rdoc")
25
- assert_equal(RDoc::Parser::Simple, RDoc::Parser.can_parse(jtest_rdoc_file_name))
68
+ def test_class_can_parse_zip
69
+ hidden_zip = File.expand_path '../hidden.zip.txt', __FILE__
70
+ assert_nil @RP.can_parse(hidden_zip)
26
71
  end
72
+
73
+ def test_class_for_binary
74
+ rp = @RP.dup
75
+
76
+ def rp.can_parse(*args) nil end
77
+
78
+ assert_nil @RP.for(nil, @binary_dat, nil, nil, nil)
79
+ end
80
+
27
81
  end
28
82
 
29
- MiniTest::Unit.autorun
@@ -35,11 +35,25 @@ class TestRDocParserC < MiniTest::Unit::TestCase
35
35
  /* Document-class: Foo
36
36
  * this is the Foo boot class
37
37
  */
38
+ VALUE cFoo = boot_defclass("Foo", rb_cObject);
39
+ EOF
40
+
41
+ klass = util_get_class content, 'cFoo'
42
+ assert_equal "this is the Foo boot class", klass.comment
43
+ assert_equal 'Object', klass.superclass
44
+ end
45
+
46
+ def test_do_classes_boot_class_nil
47
+ content = <<-EOF
48
+ /* Document-class: Foo
49
+ * this is the Foo boot class
50
+ */
38
51
  VALUE cFoo = boot_defclass("Foo", 0);
39
52
  EOF
40
53
 
41
54
  klass = util_get_class content, 'cFoo'
42
- assert_equal " this is the Foo boot class\n ", klass.comment
55
+ assert_equal "this is the Foo boot class", klass.comment
56
+ assert_equal nil, klass.superclass
43
57
  end
44
58
 
45
59
  def test_do_classes_class
@@ -51,7 +65,7 @@ VALUE cFoo = rb_define_class("Foo", rb_cObject);
51
65
  EOF
52
66
 
53
67
  klass = util_get_class content, 'cFoo'
54
- assert_equal " this is the Foo class\n ", klass.comment
68
+ assert_equal "this is the Foo class", klass.comment
55
69
  end
56
70
 
57
71
  def test_do_classes_class_under
@@ -63,7 +77,7 @@ VALUE cFoo = rb_define_class_under(rb_mKernel, "Foo", rb_cObject);
63
77
  EOF
64
78
 
65
79
  klass = util_get_class content, 'cFoo'
66
- assert_equal " this is the Foo class under Kernel\n ", klass.comment
80
+ assert_equal "this is the Foo class under Kernel", klass.comment
67
81
  end
68
82
 
69
83
  def test_do_classes_module
@@ -75,7 +89,7 @@ VALUE mFoo = rb_define_module("Foo");
75
89
  EOF
76
90
 
77
91
  klass = util_get_class content, 'mFoo'
78
- assert_equal " this is the Foo module\n ", klass.comment
92
+ assert_equal "this is the Foo module", klass.comment
79
93
  end
80
94
 
81
95
  def test_do_classes_module_under
@@ -87,7 +101,7 @@ VALUE mFoo = rb_define_module_under(rb_mKernel, "Foo");
87
101
  EOF
88
102
 
89
103
  klass = util_get_class content, 'mFoo'
90
- assert_equal " this is the Foo module under Kernel\n ", klass.comment
104
+ assert_equal "this is the Foo module under Kernel", klass.comment
91
105
  end
92
106
 
93
107
  def test_do_constants
@@ -103,7 +117,7 @@ void Init_foo(){
103
117
  /* Huzzah!: What you cheer when you roll a perfect game */
104
118
  rb_define_const(cFoo, "CHEER", rb_str_new2("Huzzah!"));
105
119
 
106
- /* TEST\:TEST: Checking to see if escaped semicolon works */
120
+ /* TEST\:TEST: Checking to see if escaped colon works */
107
121
  rb_define_const(cFoo, "TEST", rb_str_new2("TEST:TEST"));
108
122
 
109
123
  /* \\: The file separator on MS Windows */
@@ -153,48 +167,35 @@ void Init_foo(){
153
167
 
154
168
  constants = constants.map { |c| [c.name, c.value, c.comment] }
155
169
 
156
- assert_equal ['PERFECT', '300',
157
- "\n The highest possible score in bowling \n "],
170
+ assert_equal ['PERFECT', '300', 'The highest possible score in bowling '],
158
171
  constants.shift
159
172
  assert_equal ['CHEER', 'Huzzah!',
160
- "\n What you cheer when you roll a perfect game \n "],
173
+ 'What you cheer when you roll a perfect game '],
161
174
  constants.shift
162
175
  assert_equal ['TEST', 'TEST:TEST',
163
- "\n Checking to see if escaped semicolon works \n "],
176
+ 'Checking to see if escaped colon works '],
164
177
  constants.shift
165
178
  assert_equal ['MSEPARATOR', '\\',
166
- "\n The file separator on MS Windows \n "],
179
+ 'The file separator on MS Windows '],
167
180
  constants.shift
168
181
  assert_equal ['SEPARATOR', '/',
169
- "\n The file separator on Unix \n "],
182
+ 'The file separator on Unix '],
170
183
  constants.shift
171
184
  assert_equal ['STUFF', 'C:\\Program Files\\Stuff',
172
- "\n A directory on MS Windows \n "],
185
+ 'A directory on MS Windows '],
173
186
  constants.shift
174
187
  assert_equal ['NOSEMI', 'INT2FIX(99)',
175
- "\n Default definition \n "],
188
+ 'Default definition '],
176
189
  constants.shift
177
- assert_equal ['NOCOMMENT', 'rb_str_new2("No comment")', nil],
190
+ assert_equal ['NOCOMMENT', 'rb_str_new2("No comment")', ''],
178
191
  constants.shift
179
192
 
180
193
  comment = <<-EOF.chomp
181
-
182
-
183
- Multiline comment goes here because this comment spans multiple lines.
184
- Multiline comment goes here because this comment spans multiple lines.
185
-
186
-
187
- EOF
188
- assert_equal ['MULTILINE', 'INT2FIX(1)', comment], constants.shift
189
- assert_equal ['MULTILINE_VALUE', '1', comment], constants.shift
190
-
191
- comment = <<-EOF.chomp
192
-
193
- Multiline comment goes here because this comment spans multiple lines.
194
- Multiline comment goes here because this comment spans multiple lines.
195
-
196
-
194
+ Multiline comment goes here because this comment spans multiple lines.
195
+ Multiline comment goes here because this comment spans multiple lines.
197
196
  EOF
197
+ assert_equal ['MULTILINE', 'INT2FIX(1)', comment], constants.shift
198
+ assert_equal ['MULTILINE_VALUE', '1', comment], constants.shift
198
199
  assert_equal ['MULTILINE_NOT_EMPTY', 'INT2FIX(1)', comment], constants.shift
199
200
 
200
201
  assert constants.empty?, constants.inspect
@@ -213,7 +214,7 @@ Init_Foo(void) {
213
214
 
214
215
  klass = util_get_class content, 'foo'
215
216
 
216
- assert_equal " \n a comment for class Foo\n \n", klass.comment
217
+ assert_equal "a comment for class Foo", klass.comment
217
218
  end
218
219
 
219
220
  def test_find_class_comment_define_class
@@ -226,7 +227,7 @@ VALUE foo = rb_define_class("Foo", rb_cObject);
226
227
 
227
228
  klass = util_get_class content, 'foo'
228
229
 
229
- assert_equal " \n a comment for class Foo\n \n", klass.comment
230
+ assert_equal "a comment for class Foo", klass.comment
230
231
  end
231
232
 
232
233
  def test_find_class_comment_define_class_Init_Foo
@@ -245,7 +246,26 @@ Init_Foo(void) {
245
246
 
246
247
  klass = util_get_class content, 'foo'
247
248
 
248
- assert_equal " \n a comment for class Foo on Init\n \n", klass.comment
249
+ assert_equal "a comment for class Foo on Init", klass.comment
250
+ end
251
+
252
+ def test_find_class_comment_define_class_Init_Foo_no_void
253
+ content = <<-EOF
254
+ /*
255
+ * a comment for class Foo on Init
256
+ */
257
+ void
258
+ Init_Foo() {
259
+ /*
260
+ * a comment for class Foo on rb_define_class
261
+ */
262
+ VALUE foo = rb_define_class("Foo", rb_cObject);
263
+ }
264
+ EOF
265
+
266
+ klass = util_get_class content, 'foo'
267
+
268
+ assert_equal "a comment for class Foo on Init", klass.comment
249
269
  end
250
270
 
251
271
  def test_find_class_comment_define_class_bogus_comment
@@ -289,7 +309,7 @@ Init_Foo(void) {
289
309
  other_function = klass.method_list.first
290
310
 
291
311
  assert_equal 'my_method', other_function.name
292
- assert_equal " \n a comment for other_function\n \n",
312
+ assert_equal "a comment for other_function",
293
313
  other_function.comment
294
314
  assert_equal '()', other_function.params
295
315
 
@@ -322,7 +342,7 @@ Init_Foo(void) {
322
342
  other_function = klass.method_list.first
323
343
 
324
344
  assert_equal 'my_method', other_function.name
325
- assert_equal " \n a comment for other_function\n \n \n",
345
+ assert_equal "a comment for other_function",
326
346
  other_function.comment
327
347
  assert_equal '()', other_function.params
328
348
 
@@ -331,6 +351,41 @@ Init_Foo(void) {
331
351
  assert_equal "#define other_function rb_other_function", code
332
352
  end
333
353
 
354
+ def test_find_body_document_method
355
+ content = <<-EOF
356
+ /*
357
+ * Document-method: bar
358
+ * Document-method: baz
359
+ *
360
+ * a comment for bar
361
+ */
362
+ VALUE
363
+ bar() {
364
+ }
365
+
366
+ void
367
+ Init_Foo(void) {
368
+ VALUE foo = rb_define_class("Foo", rb_cObject);
369
+
370
+ rb_define_method(foo, "bar", bar, 0);
371
+ rb_define_method(foo, "baz", bar, 0);
372
+ }
373
+ EOF
374
+
375
+ klass = util_get_class content, 'foo'
376
+ assert_equal 2, klass.method_list.length
377
+
378
+ methods = klass.method_list.sort
379
+
380
+ bar = methods.first
381
+ assert_equal 'Foo#bar', bar.full_name
382
+ assert_equal "a comment for bar", bar.comment
383
+
384
+ baz = methods.last
385
+ assert_equal 'Foo#baz', baz.full_name
386
+ assert_equal "a comment for bar", bar.comment
387
+ end
388
+
334
389
  def test_define_method
335
390
  content = <<-EOF
336
391
  /*Method Comment! */
@@ -355,7 +410,7 @@ Init_IO(void) {
355
410
  klass = util_get_class content, 'rb_cIO'
356
411
  read_method = klass.method_list.first
357
412
  assert_equal "read", read_method.name
358
- assert_equal " Method Comment! \n", read_method.comment
413
+ assert_equal "Method Comment! ", read_method.comment
359
414
  end
360
415
 
361
416
  def test_define_method_private
@@ -383,7 +438,7 @@ Init_IO(void) {
383
438
  read_method = klass.method_list.first
384
439
  assert_equal 'IO#read', read_method.full_name
385
440
  assert_equal :private, read_method.visibility
386
- assert_equal " Method Comment! \n", read_method.comment
441
+ assert_equal "Method Comment! ", read_method.comment
387
442
  end
388
443
 
389
444
  def util_get_class(content, name)
@@ -1,7 +1,7 @@
1
1
  require 'stringio'
2
2
  require 'tempfile'
3
3
  require 'rubygems'
4
- require 'minitest/unit'
4
+ require 'minitest/autorun'
5
5
  require 'rdoc/options'
6
6
  require 'rdoc/parser/perl'
7
7
 
@@ -55,7 +55,7 @@ This just contains plain old documentation
55
55
  =end
56
56
  EOF
57
57
  comment = util_get_comment content
58
- assert_equal "\nThis just contains plain old documentation\n\n", comment
58
+ assert_equal 'This just contains plain old documentation', comment
59
59
  end
60
60
 
61
61
  # Get the comment of the @top_level when it has processed the input.
@@ -71,4 +71,3 @@ This just contains plain old documentation
71
71
 
72
72
  end
73
73
 
74
- MiniTest::Unit.autorun