rdoc 3.9.5 → 3.10.pre.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.

Files changed (183) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +6 -3
  3. data/History.txt +63 -13
  4. data/LICENSE.rdoc +57 -0
  5. data/Manifest.txt +60 -6
  6. data/Rakefile +24 -12
  7. data/TODO.rdoc +30 -0
  8. data/bin/rdoc +0 -2
  9. data/lib/rdoc.rb +55 -2
  10. data/lib/rdoc/alias.rb +0 -2
  11. data/lib/rdoc/anon_class.rb +0 -2
  12. data/lib/rdoc/any_method.rb +0 -3
  13. data/lib/rdoc/attr.rb +0 -2
  14. data/lib/rdoc/class_module.rb +40 -7
  15. data/lib/rdoc/code_object.rb +1 -3
  16. data/lib/rdoc/code_objects.rb +3 -21
  17. data/lib/rdoc/comment.rb +225 -0
  18. data/lib/rdoc/constant.rb +0 -2
  19. data/lib/rdoc/context.rb +37 -120
  20. data/lib/rdoc/context/section.rb +114 -0
  21. data/lib/rdoc/cross_reference.rb +16 -7
  22. data/lib/rdoc/encoding.rb +0 -2
  23. data/lib/rdoc/gauntlet.rb +1 -1
  24. data/lib/rdoc/generator.rb +7 -2
  25. data/lib/rdoc/generator/darkfish.rb +126 -20
  26. data/lib/rdoc/generator/json_index.rb +240 -0
  27. data/lib/rdoc/generator/markup.rb +17 -54
  28. data/lib/rdoc/generator/ri.rb +0 -3
  29. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  30. data/lib/rdoc/generator/template/darkfish/_head.rhtml +16 -0
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +18 -0
  32. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +8 -0
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +16 -0
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +7 -0
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +10 -0
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +10 -0
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +10 -0
  41. data/lib/rdoc/generator/template/darkfish/class.rhtml +161 -0
  42. data/lib/rdoc/generator/template/darkfish/fileinfo.rhtml +32 -0
  43. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  44. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  45. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  46. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  47. data/lib/rdoc/generator/template/darkfish/index.rhtml +16 -61
  48. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +99 -64
  49. data/lib/rdoc/generator/template/darkfish/js/jquery.js +15 -29
  50. data/lib/rdoc/generator/template/darkfish/js/search.js +94 -0
  51. data/lib/rdoc/generator/template/darkfish/page.rhtml +16 -0
  52. data/lib/rdoc/generator/template/darkfish/rdoc.css +126 -286
  53. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +50 -0
  54. data/lib/rdoc/generator/template/json_index/js/navigation.js +142 -0
  55. data/lib/rdoc/generator/template/json_index/js/searcher.js +228 -0
  56. data/lib/rdoc/ghost_method.rb +0 -2
  57. data/lib/rdoc/include.rb +0 -2
  58. data/lib/rdoc/markup.rb +204 -43
  59. data/lib/rdoc/markup/attr_changer.rb +25 -0
  60. data/lib/rdoc/markup/attr_span.rb +29 -0
  61. data/lib/rdoc/markup/attribute.rb +51 -0
  62. data/lib/rdoc/markup/document.rb +22 -1
  63. data/lib/rdoc/markup/formatter.rb +4 -11
  64. data/lib/rdoc/markup/formatter_test_case.rb +1 -2
  65. data/lib/rdoc/markup/heading.rb +44 -0
  66. data/lib/rdoc/markup/include.rb +42 -0
  67. data/lib/rdoc/markup/inline.rb +1 -144
  68. data/lib/rdoc/markup/list.rb +2 -1
  69. data/lib/rdoc/markup/parser.rb +6 -16
  70. data/lib/rdoc/markup/pre_process.rb +64 -10
  71. data/lib/rdoc/markup/raw.rb +1 -1
  72. data/lib/rdoc/markup/special.rb +40 -0
  73. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -2
  74. data/lib/rdoc/markup/to_ansi.rb +0 -2
  75. data/lib/rdoc/markup/to_bs.rb +0 -2
  76. data/lib/rdoc/markup/to_html.rb +102 -34
  77. data/lib/rdoc/markup/to_html_crossref.rb +36 -5
  78. data/lib/rdoc/markup/to_html_snippet.rb +270 -0
  79. data/lib/rdoc/markup/to_label.rb +55 -0
  80. data/lib/rdoc/markup/to_rdoc.rb +0 -3
  81. data/lib/rdoc/markup/to_table_of_contents.rb +62 -0
  82. data/lib/rdoc/markup/to_test.rb +0 -3
  83. data/lib/rdoc/markup/to_tt_only.rb +0 -3
  84. data/lib/rdoc/markup/verbatim.rb +18 -0
  85. data/lib/rdoc/meta_method.rb +0 -2
  86. data/lib/rdoc/method_attr.rb +17 -1
  87. data/lib/rdoc/normal_class.rb +0 -2
  88. data/lib/rdoc/normal_module.rb +0 -2
  89. data/lib/rdoc/options.rb +18 -3
  90. data/lib/rdoc/parser.rb +74 -42
  91. data/lib/rdoc/parser/c.rb +79 -118
  92. data/lib/rdoc/parser/rd.rb +22 -0
  93. data/lib/rdoc/parser/ruby.rb +86 -54
  94. data/lib/rdoc/parser/simple.rb +21 -9
  95. data/lib/rdoc/parser/text.rb +11 -0
  96. data/lib/rdoc/rd.rb +95 -0
  97. data/lib/rdoc/rd/block_parser.ry +638 -0
  98. data/lib/rdoc/rd/inline.rb +71 -0
  99. data/lib/rdoc/rd/inline_parser.ry +575 -0
  100. data/lib/rdoc/rdoc.rb +8 -23
  101. data/lib/rdoc/require.rb +0 -2
  102. data/lib/rdoc/ri.rb +4 -2
  103. data/lib/rdoc/ri/driver.rb +2 -6
  104. data/lib/rdoc/ri/store.rb +0 -1
  105. data/lib/rdoc/ruby_lex.rb +43 -20
  106. data/lib/rdoc/ruby_token.rb +44 -2
  107. data/lib/rdoc/single_class.rb +0 -2
  108. data/lib/rdoc/stats.rb +0 -5
  109. data/lib/rdoc/task.rb +2 -6
  110. data/lib/rdoc/test_case.rb +59 -0
  111. data/lib/rdoc/text.rb +42 -30
  112. data/lib/rdoc/token_stream.rb +45 -0
  113. data/lib/rdoc/tom_doc.rb +232 -0
  114. data/lib/rdoc/top_level.rb +36 -4
  115. data/test/test_attribute_manager.rb +26 -29
  116. data/test/test_rdoc_any_method.rb +2 -26
  117. data/test/test_rdoc_attr.rb +4 -4
  118. data/test/test_rdoc_class_module.rb +95 -12
  119. data/test/test_rdoc_code_object.rb +10 -3
  120. data/test/test_rdoc_comment.rb +504 -0
  121. data/test/test_rdoc_context.rb +60 -11
  122. data/test/test_rdoc_context_section.rb +16 -17
  123. data/test/test_rdoc_cross_reference.rb +17 -2
  124. data/test/test_rdoc_encoding.rb +4 -7
  125. data/test/test_rdoc_generator_darkfish.rb +12 -11
  126. data/test/test_rdoc_generator_json_index.rb +255 -0
  127. data/test/test_rdoc_generator_markup.rb +56 -0
  128. data/test/test_rdoc_generator_ri.rb +8 -11
  129. data/test/test_rdoc_markup.rb +9 -5
  130. data/test/test_rdoc_markup_attribute_manager.rb +5 -8
  131. data/test/test_rdoc_markup_document.rb +34 -6
  132. data/test/test_rdoc_markup_formatter.rb +11 -13
  133. data/test/test_rdoc_markup_heading.rb +20 -0
  134. data/test/test_rdoc_markup_include.rb +19 -0
  135. data/test/test_rdoc_markup_indented_paragraph.rb +4 -5
  136. data/test/test_rdoc_markup_paragraph.rb +2 -5
  137. data/test/test_rdoc_markup_parser.rb +87 -7
  138. data/test/test_rdoc_markup_pre_process.rb +60 -9
  139. data/test/test_rdoc_markup_raw.rb +4 -6
  140. data/test/test_rdoc_markup_to_ansi.rb +1 -4
  141. data/test/test_rdoc_markup_to_bs.rb +1 -4
  142. data/test/test_rdoc_markup_to_html.rb +170 -31
  143. data/test/test_rdoc_markup_to_html_crossref.rb +89 -11
  144. data/test/test_rdoc_markup_to_html_snippet.rb +668 -0
  145. data/test/test_rdoc_markup_to_label.rb +50 -0
  146. data/test/test_rdoc_markup_to_rdoc.rb +1 -4
  147. data/test/test_rdoc_markup_to_table_of_contents.rb +90 -0
  148. data/test/test_rdoc_markup_to_tt_only.rb +1 -4
  149. data/test/test_rdoc_markup_verbatim.rb +16 -0
  150. data/test/test_rdoc_method_attr.rb +16 -1
  151. data/test/test_rdoc_options.rb +17 -7
  152. data/test/test_rdoc_parser.rb +75 -6
  153. data/test/test_rdoc_parser_c.rb +56 -104
  154. data/test/test_rdoc_parser_rd.rb +52 -0
  155. data/test/test_rdoc_parser_ruby.rb +264 -323
  156. data/test/test_rdoc_parser_simple.rb +33 -17
  157. data/test/test_rdoc_rd.rb +30 -0
  158. data/test/test_rdoc_rd_block_parser.rb +527 -0
  159. data/test/test_rdoc_rd_inline.rb +63 -0
  160. data/test/test_rdoc_rd_inline_parser.rb +173 -0
  161. data/test/test_rdoc_rdoc.rb +7 -9
  162. data/test/test_rdoc_ri_driver.rb +10 -15
  163. data/test/test_rdoc_ri_paths.rb +6 -6
  164. data/test/test_rdoc_ri_store.rb +6 -13
  165. data/test/test_rdoc_ruby_lex.rb +53 -5
  166. data/test/test_rdoc_rubygems_hook.rb +2 -1
  167. data/test/test_rdoc_stats.rb +83 -103
  168. data/test/test_rdoc_task.rb +5 -4
  169. data/test/test_rdoc_text.rb +156 -11
  170. data/test/test_rdoc_token_stream.rb +42 -0
  171. data/test/test_rdoc_tom_doc.rb +458 -0
  172. data/test/test_rdoc_top_level.rb +49 -2
  173. data/test/xref_test_case.rb +4 -8
  174. metadata +217 -111
  175. metadata.gz.sig +0 -0
  176. checksums.yaml +0 -7
  177. checksums.yaml.gz.sig +0 -0
  178. data/CVE-2013-0256.rdoc +0 -49
  179. data/LICENSE.txt +0 -57
  180. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -321
  181. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
  182. data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
  183. data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
@@ -0,0 +1,52 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocParserRd < RDoc::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ @RP = RDoc::Parser
9
+
10
+ @tempfile = Tempfile.new self.class.name
11
+ filename = @tempfile.path
12
+
13
+ @top_level = RDoc::TopLevel.new filename
14
+ @fn = filename
15
+ @options = RDoc::Options.new
16
+ @stats = RDoc::Stats.new 0
17
+ end
18
+
19
+ def teardown
20
+ super
21
+
22
+ @tempfile.close
23
+ end
24
+
25
+ def test_file
26
+ assert_kind_of RDoc::Parser::Text, util_parser('')
27
+ end
28
+
29
+ def test_class_can_parse
30
+ assert_equal @RP::RD, @RP.can_parse('foo.rd')
31
+ assert_equal @RP::RD, @RP.can_parse('foo.rd.ja')
32
+ end
33
+
34
+ def test_scan
35
+ parser = util_parser 'it ((*really*)) works'
36
+
37
+ expected =
38
+ @RM::Document.new(
39
+ @RM::Paragraph.new('it <em>really</em> works'))
40
+ expected.file = @top_level
41
+
42
+ parser.scan
43
+
44
+ assert_equal expected, @top_level.comment.parse
45
+ end
46
+
47
+ def util_parser content
48
+ RDoc::Parser::RD.new @top_level, @fn, content, @options, @stats
49
+ end
50
+
51
+ end
52
+
@@ -1,17 +1,12 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'stringio'
4
- require 'tempfile'
5
- require 'rubygems'
6
- require 'minitest/autorun'
3
+ require 'rdoc/test_case'
7
4
 
8
- require 'rdoc/options'
9
- require 'rdoc/parser/ruby'
10
- require 'rdoc/stats'
11
-
12
- class TestRDocParserRuby < MiniTest::Unit::TestCase
5
+ class TestRDocParserRuby < RDoc::TestCase
13
6
 
14
7
  def setup
8
+ super
9
+
15
10
  @tempfile = Tempfile.new self.class.name
16
11
  @filename = @tempfile.path
17
12
 
@@ -24,14 +19,25 @@ class TestRDocParserRuby < MiniTest::Unit::TestCase
24
19
  @options.quiet = true
25
20
  @options.option_parser = OptionParser.new
26
21
 
22
+ @comment = RDoc::Comment.new '', @top_level
23
+
27
24
  @stats = RDoc::Stats.new 0
28
25
  end
29
26
 
30
27
  def teardown
28
+ super
29
+
31
30
  @tempfile.close
32
31
  @tempfile2.close
33
32
  end
34
33
 
34
+ def mu_pp obj
35
+ s = ''
36
+ s = PP.pp obj, s
37
+ s = s.force_encoding(Encoding.default_external) if defined? Encoding
38
+ s.chomp
39
+ end
40
+
35
41
  def test_collect_first_comment
36
42
  p = util_parser <<-CONTENT
37
43
  # first
@@ -42,7 +48,7 @@ class C; end
42
48
 
43
49
  comment = p.collect_first_comment
44
50
 
45
- assert_equal "# first\n", comment
51
+ assert_equal RDoc::Comment.new("# first\n", @top_level), comment
46
52
  end
47
53
 
48
54
  def test_collect_first_comment_encoding
@@ -59,67 +65,7 @@ class C; end
59
65
 
60
66
  comment = p.collect_first_comment
61
67
 
62
- assert_equal Encoding::CP852, comment.encoding
63
- end
64
-
65
- def test_extract_call_seq
66
- m = RDoc::AnyMethod.new nil, 'm'
67
- p = util_parser ''
68
-
69
- comment = <<-COMMENT
70
- # call-seq:
71
- # bla => true or false
72
- #
73
- # moar comment
74
- COMMENT
75
-
76
- p.extract_call_seq comment, m
77
-
78
- assert_equal "bla => true or false\n", m.call_seq
79
- end
80
-
81
- def test_extract_call_seq_blank
82
- m = RDoc::AnyMethod.new nil, 'm'
83
- p = util_parser ''
84
-
85
- comment = <<-COMMENT
86
- # call-seq:
87
- # bla => true or false
88
- #
89
- COMMENT
90
-
91
- p.extract_call_seq comment, m
92
-
93
- assert_equal "bla => true or false\n", m.call_seq
94
- end
95
-
96
- def test_extract_call_seq_no_blank
97
- m = RDoc::AnyMethod.new nil, 'm'
98
- p = util_parser ''
99
-
100
- comment = <<-COMMENT
101
- # call-seq:
102
- # bla => true or false
103
- COMMENT
104
-
105
- p.extract_call_seq comment, m
106
-
107
- assert_equal "bla => true or false\n", m.call_seq
108
- end
109
-
110
- def test_extract_call_seq_undent
111
- m = RDoc::AnyMethod.new nil, 'm'
112
- p = util_parser ''
113
-
114
- comment = <<-COMMENT
115
- # call-seq:
116
- # bla => true or false
117
- # moar comment
118
- COMMENT
119
-
120
- p.extract_call_seq comment, m
121
-
122
- assert_equal "bla => true or false\nmoar comment\n", m.call_seq
68
+ assert_equal Encoding::CP852, comment.text.encoding
123
69
  end
124
70
 
125
71
  def test_get_symbol_or_name
@@ -149,159 +95,32 @@ class C; end
149
95
  def test_look_for_directives_in_attr
150
96
  util_parser ""
151
97
 
152
- comment = "# :attr: my_attr\n"
98
+ comment = RDoc::Comment.new "# :attr: my_attr\n", @top_level
153
99
 
154
100
  @parser.look_for_directives_in @top_level, comment
155
101
 
156
- assert_equal "# :attr: my_attr\n", comment
102
+ assert_equal "# :attr: my_attr\n", comment.text
157
103
 
158
- comment = "# :attr_reader: my_method\n"
104
+ comment = RDoc::Comment.new "# :attr_reader: my_method\n", @top_level
159
105
 
160
106
  @parser.look_for_directives_in @top_level, comment
161
107
 
162
- assert_equal "# :attr_reader: my_method\n", comment
108
+ assert_equal "# :attr_reader: my_method\n", comment.text
163
109
 
164
- comment = "# :attr_writer: my_method\n"
110
+ comment = RDoc::Comment.new "# :attr_writer: my_method\n", @top_level
165
111
 
166
112
  @parser.look_for_directives_in @top_level, comment
167
113
 
168
- assert_equal "# :attr_writer: my_method\n", comment
169
- end
170
-
171
- def test_remove_private_comments
172
- util_parser ''
173
-
174
- comment = <<-EOS
175
- # This is text
176
- #--
177
- # this is private
178
- EOS
179
-
180
- expected = <<-EOS
181
- # This is text
182
- EOS
183
-
184
- @parser.remove_private_comments(comment)
185
-
186
- assert_equal expected, comment
187
- end
188
-
189
- def test_remove_private_comments_encoding
190
- skip "Encoding not implemented" unless Object.const_defined? :Encoding
191
-
192
- util_parser ''
193
-
194
- comment = <<-EOS
195
- # This is text
196
- #--
197
- # this is private
198
- EOS
199
- comment.force_encoding Encoding::IBM437
200
-
201
- @parser.remove_private_comments comment
202
-
203
- assert_equal Encoding::IBM437, comment.encoding
204
- end
205
-
206
- def test_remove_private_comments_long
207
- util_parser ''
208
-
209
- comment = <<-EOS
210
- #-----
211
- #++
212
- # this is text
213
- #-----
214
- EOS
215
-
216
- expected = <<-EOS
217
- # this is text
218
- EOS
219
-
220
- @parser.remove_private_comments(comment)
221
-
222
- assert_equal expected, comment
223
- end
224
-
225
- def test_remove_private_comments_rule
226
- util_parser ''
227
-
228
- comment = <<-EOS
229
- # This is text with a rule:
230
- # ---
231
- # this is also text
232
- EOS
233
-
234
- expected = comment.dup
235
-
236
- @parser.remove_private_comments(comment)
237
-
238
- assert_equal expected, comment
239
- end
240
-
241
- def test_remove_private_comments_toggle
242
- util_parser ''
243
-
244
- comment = <<-EOS
245
- # This is text
246
- #--
247
- # this is private
248
- #++
249
- # This is text again.
250
- EOS
251
-
252
- expected = <<-EOS
253
- # This is text
254
- # This is text again.
255
- EOS
256
-
257
- @parser.remove_private_comments(comment)
258
-
259
- assert_equal expected, comment
260
- end
261
-
262
- def test_remove_private_comments_toggle_encoding
263
- skip "Encoding not implemented" unless Object.const_defined? :Encoding
264
-
265
- util_parser ''
266
-
267
- comment = <<-EOS
268
- # This is text
269
- #--
270
- # this is private
271
- #++
272
- # This is text again.
273
- EOS
274
-
275
- comment.force_encoding Encoding::IBM437
276
-
277
- @parser.remove_private_comments comment
278
-
279
- assert_equal Encoding::IBM437, comment.encoding
280
- end
281
-
282
- def test_remove_private_comments_toggle_encoding_ruby_bug?
283
- skip "Encoding not implemented" unless Object.const_defined? :Encoding
284
-
285
- util_parser ''
286
-
287
- comment = <<-EOS
288
- #--
289
- # this is private
290
- #++
291
- # This is text again.
292
- EOS
293
-
294
- comment.force_encoding Encoding::IBM437
295
-
296
- @parser.remove_private_comments comment
297
-
298
- assert_equal Encoding::IBM437, comment.encoding
114
+ assert_equal "# :attr_writer: my_method\n", comment.text
299
115
  end
300
116
 
301
117
  def test_look_for_directives_in_commented
302
118
  util_parser ""
303
119
 
304
- comment = "# how to make a section:\n# # :section: new section\n"
120
+ comment = RDoc::Comment.new <<-COMMENT, @top_level
121
+ # how to make a section:
122
+ # # :section: new section
123
+ COMMENT
305
124
 
306
125
  @parser.look_for_directives_in @top_level, comment
307
126
 
@@ -310,43 +129,48 @@ class C; end
310
129
  assert_equal nil, section.comment
311
130
 
312
131
  assert_equal "# how to make a section:\n# # :section: new section\n",
313
- comment
132
+ comment.text
314
133
  end
315
134
 
316
135
  def test_look_for_directives_in_method
317
136
  util_parser ""
318
137
 
319
- comment = "# :method: my_method\n"
138
+ comment = RDoc::Comment.new "# :method: my_method\n", @top_level
320
139
 
321
140
  @parser.look_for_directives_in @top_level, comment
322
141
 
323
- assert_equal "# :method: my_method\n", comment
142
+ assert_equal "# :method: my_method\n", comment.text
324
143
 
325
- comment = "# :singleton-method: my_method\n"
144
+ comment = RDoc::Comment.new "# :singleton-method: my_method\n", @top_level
326
145
 
327
146
  @parser.look_for_directives_in @top_level, comment
328
147
 
329
- assert_equal "# :singleton-method: my_method\n", comment
148
+ assert_equal "# :singleton-method: my_method\n", comment.text
330
149
  end
331
150
 
332
151
  def test_look_for_directives_in_section
333
152
  util_parser ""
334
153
 
335
- comment = "# :section: new section\n# woo stuff\n"
154
+ comment = RDoc::Comment.new <<-COMMENT, @top_level
155
+ # :section: new section
156
+ # woo stuff
157
+ COMMENT
336
158
 
337
159
  @parser.look_for_directives_in @top_level, comment
338
160
 
339
161
  section = @top_level.current_section
340
162
  assert_equal 'new section', section.title
341
- assert_equal "# woo stuff\n", section.comment
163
+ assert_equal "# woo stuff\n", section.comment.text
342
164
 
343
- assert_equal '', comment
165
+ assert_empty comment
344
166
  end
345
167
 
346
168
  def test_look_for_directives_in_unhandled
347
169
  util_parser ""
348
170
 
349
- @parser.look_for_directives_in @top_level, "# :unhandled: blah\n"
171
+ comment = RDoc::Comment.new "# :unhandled: blah\n", @top_level
172
+
173
+ @parser.look_for_directives_in @top_level, comment
350
174
 
351
175
  assert_equal 'blah', @top_level.metadata['unhandled']
352
176
  end
@@ -420,7 +244,7 @@ class C; end
420
244
  klass = RDoc::NormalClass.new 'Foo'
421
245
  klass.parent = @top_level
422
246
 
423
- comment = "##\n# my attr\n"
247
+ comment = RDoc::Comment.new "##\n# my attr\n", @top_level
424
248
 
425
249
  util_parser "attr :foo, :bar"
426
250
 
@@ -432,7 +256,7 @@ class C; end
432
256
 
433
257
  foo = klass.attributes.first
434
258
  assert_equal 'foo', foo.name
435
- assert_equal 'my attr', foo.comment
259
+ assert_equal 'my attr', foo.comment.text
436
260
  assert_equal @top_level, foo.file
437
261
  assert_equal 0, foo.offset
438
262
  assert_equal 1, foo.line
@@ -443,7 +267,7 @@ class C; end
443
267
  klass.parent = @top_level
444
268
  klass.stop_doc
445
269
 
446
- comment = "##\n# my attr\n"
270
+ comment = RDoc::Comment.new "##\n# my attr\n", @top_level
447
271
 
448
272
  util_parser "attr :foo, :bar"
449
273
 
@@ -458,7 +282,7 @@ class C; end
458
282
  klass = RDoc::NormalClass.new 'Foo'
459
283
  klass.parent = @top_level
460
284
 
461
- comment = "##\n# my attr\n"
285
+ comment = RDoc::Comment.new "##\n# my attr\n", @top_level
462
286
 
463
287
  util_parser "attr_accessor :foo, :bar"
464
288
 
@@ -471,7 +295,7 @@ class C; end
471
295
  foo = klass.attributes.first
472
296
  assert_equal 'foo', foo.name
473
297
  assert_equal 'RW', foo.rw
474
- assert_equal 'my attr', foo.comment
298
+ assert_equal 'my attr', foo.comment.text
475
299
  assert_equal @top_level, foo.file
476
300
  assert_equal 0, foo.offset
477
301
  assert_equal 1, foo.line
@@ -479,14 +303,14 @@ class C; end
479
303
  bar = klass.attributes.last
480
304
  assert_equal 'bar', bar.name
481
305
  assert_equal 'RW', bar.rw
482
- assert_equal 'my attr', bar.comment
306
+ assert_equal 'my attr', bar.comment.text
483
307
  end
484
308
 
485
309
  def test_parse_attr_accessor_nodoc
486
310
  klass = RDoc::NormalClass.new 'Foo'
487
311
  klass.parent = @top_level
488
312
 
489
- comment = "##\n# my attr\n"
313
+ comment = RDoc::Comment.new "##\n# my attr\n", @top_level
490
314
 
491
315
  util_parser "attr_accessor :foo, :bar # :nodoc:"
492
316
 
@@ -502,7 +326,7 @@ class C; end
502
326
  klass.parent = @top_level
503
327
  klass.stop_doc
504
328
 
505
- comment = "##\n# my attr\n"
329
+ comment = RDoc::Comment.new "##\n# my attr\n", @top_level
506
330
 
507
331
  util_parser "attr_accessor :foo, :bar"
508
332
 
@@ -517,7 +341,7 @@ class C; end
517
341
  klass = RDoc::NormalClass.new 'Foo'
518
342
  klass.parent = @top_level
519
343
 
520
- comment = "##\n# my attr\n"
344
+ comment = RDoc::Comment.new "##\n# my attr\n", @top_level
521
345
 
522
346
  util_parser "attr_writer :foo, :bar"
523
347
 
@@ -530,20 +354,20 @@ class C; end
530
354
  foo = klass.attributes.first
531
355
  assert_equal 'foo', foo.name
532
356
  assert_equal 'W', foo.rw
533
- assert_equal "my attr", foo.comment
357
+ assert_equal "my attr", foo.comment.text
534
358
  assert_equal @top_level, foo.file
535
359
 
536
360
  bar = klass.attributes.last
537
361
  assert_equal 'bar', bar.name
538
362
  assert_equal 'W', bar.rw
539
- assert_equal "my attr", bar.comment
363
+ assert_equal "my attr", bar.comment.text
540
364
  end
541
365
 
542
366
  def test_parse_meta_attr
543
367
  klass = RDoc::NormalClass.new 'Foo'
544
368
  klass.parent = @top_level
545
369
 
546
- comment = "##\n# :attr: \n# my method\n"
370
+ comment = RDoc::Comment.new "##\n# :attr: \n# my method\n", @top_level
547
371
 
548
372
  util_parser "add_my_method :foo, :bar"
549
373
 
@@ -555,7 +379,7 @@ class C; end
555
379
  foo = klass.attributes.first
556
380
  assert_equal 'foo', foo.name
557
381
  assert_equal 'RW', foo.rw
558
- assert_equal "my method", foo.comment
382
+ assert_equal "my method", foo.comment.text
559
383
  assert_equal @top_level, foo.file
560
384
  end
561
385
 
@@ -563,7 +387,8 @@ class C; end
563
387
  klass = RDoc::NormalClass.new 'Foo'
564
388
  klass.parent = @top_level
565
389
 
566
- comment = "##\n# :attr_accessor: \n# my method\n"
390
+ comment =
391
+ RDoc::Comment.new "##\n# :attr_accessor: \n# my method\n", @top_level
567
392
 
568
393
  util_parser "add_my_method :foo, :bar"
569
394
 
@@ -575,7 +400,7 @@ class C; end
575
400
  foo = klass.attributes.first
576
401
  assert_equal 'foo', foo.name
577
402
  assert_equal 'RW', foo.rw
578
- assert_equal 'my method', foo.comment
403
+ assert_equal 'my method', foo.comment.text
579
404
  assert_equal @top_level, foo.file
580
405
  end
581
406
 
@@ -583,7 +408,7 @@ class C; end
583
408
  klass = RDoc::NormalClass.new 'Foo'
584
409
  klass.parent = @top_level
585
410
 
586
- comment = "##\n# :attr: foo\n# my method\n"
411
+ comment = RDoc::Comment.new "##\n# :attr: foo\n# my method\n", @top_level
587
412
 
588
413
  util_parser "add_my_method :foo, :bar"
589
414
 
@@ -595,7 +420,7 @@ class C; end
595
420
  foo = klass.attributes.first
596
421
  assert_equal 'foo', foo.name
597
422
  assert_equal 'RW', foo.rw
598
- assert_equal 'my method', foo.comment
423
+ assert_equal 'my method', foo.comment.text
599
424
  assert_equal @top_level, foo.file
600
425
  end
601
426
 
@@ -603,7 +428,8 @@ class C; end
603
428
  klass = RDoc::NormalClass.new 'Foo'
604
429
  klass.parent = @top_level
605
430
 
606
- comment = "##\n# :attr_reader: \n# my method\n"
431
+ comment =
432
+ RDoc::Comment.new "##\n# :attr_reader: \n# my method\n", @top_level
607
433
 
608
434
  util_parser "add_my_method :foo, :bar"
609
435
 
@@ -614,7 +440,7 @@ class C; end
614
440
  foo = klass.attributes.first
615
441
  assert_equal 'foo', foo.name
616
442
  assert_equal 'R', foo.rw
617
- assert_equal 'my method', foo.comment
443
+ assert_equal 'my method', foo.comment.text
618
444
  assert_equal @top_level, foo.file
619
445
  end
620
446
 
@@ -623,7 +449,7 @@ class C; end
623
449
  klass.parent = @top_level
624
450
  klass.stop_doc
625
451
 
626
- comment = "##\n# :attr: \n# my method\n"
452
+ comment = RDoc::Comment.new "##\n# :attr: \n# my method\n", @top_level
627
453
 
628
454
  util_parser "add_my_method :foo, :bar"
629
455
 
@@ -638,7 +464,8 @@ class C; end
638
464
  klass = RDoc::NormalClass.new 'Foo'
639
465
  klass.parent = @top_level
640
466
 
641
- comment = "##\n# :attr_writer: \n# my method\n"
467
+ comment =
468
+ RDoc::Comment.new "##\n# :attr_writer: \n# my method\n", @top_level
642
469
 
643
470
  util_parser "add_my_method :foo, :bar"
644
471
 
@@ -649,12 +476,12 @@ class C; end
649
476
  foo = klass.attributes.first
650
477
  assert_equal 'foo', foo.name
651
478
  assert_equal 'W', foo.rw
652
- assert_equal "my method", foo.comment
479
+ assert_equal "my method", foo.comment.text
653
480
  assert_equal @top_level, foo.file
654
481
  end
655
482
 
656
483
  def test_parse_class
657
- comment = "##\n# my class\n"
484
+ comment = RDoc::Comment.new "##\n# my class\n", @top_level
658
485
 
659
486
  util_parser "class Foo\nend"
660
487
 
@@ -664,7 +491,7 @@ class C; end
664
491
 
665
492
  foo = @top_level.classes.first
666
493
  assert_equal 'Foo', foo.full_name
667
- assert_equal 'my class', foo.comment
494
+ assert_equal 'my class', foo.comment.text
668
495
  assert_equal [@top_level], foo.in_files
669
496
  assert_equal 0, foo.offset
670
497
  assert_equal 1, foo.line
@@ -681,7 +508,7 @@ end
681
508
 
682
509
  tk = @parser.get_tk
683
510
 
684
- @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, ''
511
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
685
512
 
686
513
  foo = @top_level.classes.first
687
514
  assert_equal 'Foo', foo.full_name
@@ -712,7 +539,7 @@ end
712
539
 
713
540
  tk = @parser.get_tk
714
541
 
715
- @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, ''
542
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
716
543
 
717
544
  foo = @top_level.classes.first
718
545
  assert_equal 'Foo', foo.full_name
@@ -721,7 +548,7 @@ end
721
548
  end
722
549
 
723
550
  def test_parse_class_nodoc
724
- comment = "##\n# my class\n"
551
+ comment = RDoc::Comment.new "##\n# my class\n", @top_level
725
552
 
726
553
  util_parser "class Foo # :nodoc:\nend"
727
554
 
@@ -740,7 +567,7 @@ end
740
567
  def test_parse_class_stopdoc
741
568
  @top_level.stop_doc
742
569
 
743
- comment = "##\n# my class\n"
570
+ comment = RDoc::Comment.new "##\n# my class\n", @top_level
744
571
 
745
572
  util_parser "class Foo\nend"
746
573
 
@@ -772,7 +599,7 @@ end
772
599
 
773
600
  tk = @parser.get_tk
774
601
 
775
- @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, ''
602
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
776
603
 
777
604
  foo = @top_level.classes.first
778
605
  assert_equal 'Foo', foo.full_name
@@ -794,7 +621,7 @@ end
794
621
 
795
622
  tk = @parser.get_tk
796
623
 
797
- @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, ''
624
+ @parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
798
625
 
799
626
  const_fail_meta = @top_level.classes.first
800
627
  assert_equal 'ConstFailMeta', const_fail_meta.full_name
@@ -810,14 +637,14 @@ end
810
637
 
811
638
  tk = @parser.get_tk
812
639
 
813
- @parser.parse_class foo, RDoc::Parser::Ruby::NORMAL, tk, ''
640
+ @parser.parse_class foo, RDoc::Parser::Ruby::NORMAL, tk, @comment
814
641
 
815
642
  bar = foo.classes.first
816
643
  assert_equal 'Super', bar.superclass
817
644
  end
818
645
 
819
646
  def test_parse_module
820
- comment = "##\n# my module\n"
647
+ comment = RDoc::Comment.new "##\n# my module\n", @top_level
821
648
 
822
649
  util_parser "module Foo\nend"
823
650
 
@@ -827,13 +654,13 @@ end
827
654
 
828
655
  foo = @top_level.modules.first
829
656
  assert_equal 'Foo', foo.full_name
830
- assert_equal 'my module', foo.comment
657
+ assert_equal 'my module', foo.comment.text
831
658
  end
832
659
 
833
660
  def test_parse_module_nodoc
834
661
  @top_level.stop_doc
835
662
 
836
- comment = "##\n# my module\n"
663
+ comment = RDoc::Comment.new "##\n# my module\n", @top_level
837
664
 
838
665
  util_parser "module Foo # :nodoc:\nend"
839
666
 
@@ -849,7 +676,7 @@ end
849
676
  def test_parse_module_stopdoc
850
677
  @top_level.stop_doc
851
678
 
852
- comment = "##\n# my module\n"
679
+ comment = RDoc::Comment.new "##\n# my module\n", @top_level
853
680
 
854
681
  util_parser "module Foo\nend"
855
682
 
@@ -859,7 +686,7 @@ end
859
686
 
860
687
  foo = @top_level.modules.first
861
688
  assert_equal 'Foo', foo.full_name
862
- assert_equal 'my module', foo.comment
689
+ assert_equal 'my module', foo.comment.text
863
690
  end
864
691
 
865
692
  def test_parse_class_colon3
@@ -872,7 +699,7 @@ end
872
699
 
873
700
  util_parser code
874
701
 
875
- @parser.parse_class @top_level, false, @parser.get_tk, ''
702
+ @parser.parse_class @top_level, false, @parser.get_tk, @comment
876
703
 
877
704
  assert_equal %w[A B], RDoc::TopLevel.classes.map { |c| c.full_name }
878
705
  end
@@ -891,7 +718,7 @@ end
891
718
 
892
719
  util_parser code
893
720
 
894
- @parser.parse_class @top_level, false, @parser.get_tk, ''
721
+ @parser.parse_class @top_level, false, @parser.get_tk, @comment
895
722
 
896
723
  assert_equal %w[A], RDoc::TopLevel.classes.map { |c| c.full_name }
897
724
  assert_equal %w[A::B A::d], RDoc::TopLevel.modules.map { |c| c.full_name }
@@ -925,7 +752,7 @@ end
925
752
 
926
753
  util_parser code
927
754
 
928
- @parser.parse_module @top_level, false, @parser.get_tk, ''
755
+ @parser.parse_module @top_level, false, @parser.get_tk, @comment
929
756
 
930
757
  assert_equal %w[A], RDoc::TopLevel.modules.map { |c| c.full_name }
931
758
  assert_equal %w[A::B A::C A::Object], RDoc::TopLevel.classes.map { |c| c.full_name }.sort
@@ -997,13 +824,14 @@ end
997
824
  end
998
825
 
999
826
  def test_parse_module_relative_to_top_level_namespace
1000
- comment = <<-EOF
827
+ comment = RDoc::Comment.new <<-EOF, @top_level
1001
828
  #
1002
829
  # Weirdly named module
1003
830
  #
1004
831
  EOF
1005
832
 
1006
- code = comment + <<-EOF
833
+ code = <<-EOF
834
+ #{comment.text}
1007
835
  module ::Foo
1008
836
  class Helper
1009
837
  end
@@ -1015,7 +843,7 @@ EOF
1015
843
 
1016
844
  foo = @top_level.modules.first
1017
845
  assert_equal 'Foo', foo.full_name
1018
- assert_equal 'Weirdly named module', foo.comment
846
+ assert_equal 'Weirdly named module', foo.comment.text
1019
847
 
1020
848
  helper = foo.classes.first
1021
849
  assert_equal 'Foo::Helper', helper.full_name
@@ -1025,7 +853,7 @@ EOF
1025
853
  klass = RDoc::NormalClass.new 'Foo'
1026
854
  klass.parent = @top_level
1027
855
 
1028
- comment = "##\n# :attr: foo\n# my attr\n"
856
+ comment = RDoc::Comment.new "##\n# :attr: foo\n# my attr\n", @top_level
1029
857
 
1030
858
  util_parser "\n"
1031
859
 
@@ -1036,7 +864,7 @@ EOF
1036
864
  foo = klass.attributes.first
1037
865
  assert_equal 'foo', foo.name
1038
866
  assert_equal 'RW', foo.rw
1039
- assert_equal 'my attr', foo.comment
867
+ assert_equal 'my attr', foo.comment.text
1040
868
  assert_equal @top_level, foo.file
1041
869
  assert_equal 0, foo.offset
1042
870
  assert_equal 1, foo.line
@@ -1058,7 +886,7 @@ EOF
1058
886
  klass.parent = @top_level
1059
887
  klass.stop_doc
1060
888
 
1061
- comment = "##\n# :attr: foo\n# my attr\n"
889
+ comment = RDoc::Comment.new "##\n# :attr: foo\n# my attr\n", @top_level
1062
890
 
1063
891
  util_parser "\n"
1064
892
 
@@ -1073,7 +901,7 @@ EOF
1073
901
  klass = RDoc::NormalClass.new 'Foo'
1074
902
  klass.parent = @top_level
1075
903
 
1076
- comment = "##\n# :method: foo\n# my method\n"
904
+ comment = RDoc::Comment.new "##\n# :method: foo\n# my method\n", @top_level
1077
905
 
1078
906
  util_parser "\n"
1079
907
 
@@ -1083,7 +911,7 @@ EOF
1083
911
 
1084
912
  foo = klass.method_list.first
1085
913
  assert_equal 'foo', foo.name
1086
- assert_equal 'my method', foo.comment
914
+ assert_equal 'my method', foo.comment.text
1087
915
  assert_equal @top_level, foo.file
1088
916
  assert_equal 0, foo.offset
1089
917
  assert_equal 1, foo.line
@@ -1119,7 +947,7 @@ EOF
1119
947
  klass.parent = @top_level
1120
948
  klass.stop_doc
1121
949
 
1122
- comment = "##\n# :method: foo\n# my method\n"
950
+ comment = RDoc::Comment.new "##\n# :method: foo\n# my method\n", @top_level
1123
951
 
1124
952
  util_parser "\n"
1125
953
 
@@ -1139,7 +967,7 @@ EOF
1139
967
 
1140
968
  tk = @parser.get_tk
1141
969
 
1142
- @parser.parse_constant klass, tk, ''
970
+ @parser.parse_constant klass, tk, @comment
1143
971
 
1144
972
  foo = klass.constants.first
1145
973
 
@@ -1158,7 +986,7 @@ EOF
1158
986
 
1159
987
  tk = @parser.get_tk
1160
988
 
1161
- @parser.parse_constant klass, tk, ''
989
+ @parser.parse_constant klass, tk, @comment
1162
990
 
1163
991
  assert klass.constants.empty?
1164
992
  end
@@ -1172,7 +1000,7 @@ EOF
1172
1000
 
1173
1001
  tk = @parser.get_tk
1174
1002
 
1175
- @parser.parse_constant klass, tk, ''
1003
+ @parser.parse_constant klass, tk, @comment
1176
1004
 
1177
1005
  assert_equal cB, klass.find_module_named('A')
1178
1006
  end
@@ -1188,7 +1016,7 @@ EOF
1188
1016
 
1189
1017
  tk = @parser.get_tk
1190
1018
 
1191
- @parser.parse_constant foo, tk, ''
1019
+ @parser.parse_constant foo, tk, @comment
1192
1020
 
1193
1021
  assert_equal top_bar, bar.find_module_named('A')
1194
1022
  end
@@ -1203,7 +1031,7 @@ EOF
1203
1031
 
1204
1032
  tk = @parser.get_tk
1205
1033
 
1206
- @parser.parse_constant klass, tk, ''
1034
+ @parser.parse_constant klass, tk, @comment
1207
1035
 
1208
1036
  assert_empty klass.constants
1209
1037
  end
@@ -1212,7 +1040,7 @@ EOF
1212
1040
  klass = RDoc::NormalClass.new 'C'
1213
1041
  klass.parent = @top_level
1214
1042
 
1215
- comment = "# my include\n"
1043
+ comment = RDoc::Comment.new "# my include\n", @top_level
1216
1044
 
1217
1045
  util_parser "include I"
1218
1046
 
@@ -1224,7 +1052,7 @@ EOF
1224
1052
 
1225
1053
  incl = klass.includes.first
1226
1054
  assert_equal 'I', incl.name
1227
- assert_equal 'my include', incl.comment
1055
+ assert_equal 'my include', incl.comment.text
1228
1056
  assert_equal @top_level, incl.file
1229
1057
  end
1230
1058
 
@@ -1232,7 +1060,7 @@ EOF
1232
1060
  klass = RDoc::NormalClass.new 'Foo'
1233
1061
  klass.parent = @top_level
1234
1062
 
1235
- comment = "##\n# my method\n"
1063
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
1236
1064
 
1237
1065
  util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
1238
1066
 
@@ -1242,7 +1070,7 @@ EOF
1242
1070
 
1243
1071
  foo = klass.method_list.first
1244
1072
  assert_equal 'foo', foo.name
1245
- assert_equal 'my method', foo.comment
1073
+ assert_equal 'my method', foo.comment.text
1246
1074
  assert_equal @top_level, foo.file
1247
1075
  assert_equal 0, foo.offset
1248
1076
  assert_equal 1, foo.line
@@ -1284,7 +1112,7 @@ EOF
1284
1112
  klass = RDoc::NormalClass.new 'Foo'
1285
1113
  klass.parent = @top_level
1286
1114
 
1287
- comment = "##\n# my method\n"
1115
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
1288
1116
 
1289
1117
  content = <<-CONTENT
1290
1118
  inline(:my_method) do |*args|
@@ -1305,7 +1133,8 @@ end
1305
1133
  klass = RDoc::NormalClass.new 'Foo'
1306
1134
  klass.parent = @top_level
1307
1135
 
1308
- comment = "##\n# :method: woo_hoo!\n# my method\n"
1136
+ comment =
1137
+ RDoc::Comment.new "##\n# :method: woo_hoo!\n# my method\n", @top_level
1309
1138
 
1310
1139
  util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
1311
1140
 
@@ -1315,7 +1144,7 @@ end
1315
1144
 
1316
1145
  foo = klass.method_list.first
1317
1146
  assert_equal 'woo_hoo!', foo.name
1318
- assert_equal 'my method', foo.comment
1147
+ assert_equal 'my method', foo.comment.text
1319
1148
  assert_equal @top_level, foo.file
1320
1149
  end
1321
1150
 
@@ -1323,7 +1152,8 @@ end
1323
1152
  klass = RDoc::NormalClass.new 'Foo'
1324
1153
  klass.parent = @top_level
1325
1154
 
1326
- comment = "##\n# :singleton-method:\n# my method\n"
1155
+ comment =
1156
+ RDoc::Comment.new "##\n# :singleton-method:\n# my method\n", @top_level
1327
1157
 
1328
1158
  util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
1329
1159
 
@@ -1334,7 +1164,7 @@ end
1334
1164
  foo = klass.method_list.first
1335
1165
  assert_equal 'foo', foo.name
1336
1166
  assert_equal true, foo.singleton, 'singleton method'
1337
- assert_equal 'my method', foo.comment
1167
+ assert_equal 'my method', foo.comment.text
1338
1168
  assert_equal @top_level, foo.file
1339
1169
  end
1340
1170
 
@@ -1342,7 +1172,9 @@ end
1342
1172
  klass = RDoc::NormalClass.new 'Foo'
1343
1173
  klass.parent = @top_level
1344
1174
 
1345
- comment = "##\n# :singleton-method: woo_hoo!\n# my method\n"
1175
+ comment =
1176
+ RDoc::Comment.new "##\n# :singleton-method: woo_hoo!\n# my method\n",
1177
+ @top_level
1346
1178
 
1347
1179
  util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
1348
1180
 
@@ -1353,13 +1185,13 @@ end
1353
1185
  foo = klass.method_list.first
1354
1186
  assert_equal 'woo_hoo!', foo.name
1355
1187
  assert_equal true, foo.singleton, 'singleton method'
1356
- assert_equal 'my method', foo.comment
1188
+ assert_equal 'my method', foo.comment.text
1357
1189
  assert_equal @top_level, foo.file
1358
1190
  end
1359
1191
 
1360
1192
  def test_parse_meta_method_string_name
1361
1193
  klass = RDoc::NormalClass.new 'Foo'
1362
- comment = "##\n# my method\n"
1194
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
1363
1195
 
1364
1196
  util_parser "add_my_method 'foo'"
1365
1197
 
@@ -1369,7 +1201,7 @@ end
1369
1201
 
1370
1202
  foo = klass.method_list.first
1371
1203
  assert_equal 'foo', foo.name
1372
- assert_equal 'my method', foo.comment
1204
+ assert_equal 'my method', foo.comment.text
1373
1205
  assert_equal @top_level, foo.file
1374
1206
  end
1375
1207
 
@@ -1378,7 +1210,7 @@ end
1378
1210
  klass.parent = @top_level
1379
1211
  klass.stop_doc
1380
1212
 
1381
- comment = "##\n# my method\n"
1213
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
1382
1214
 
1383
1215
  util_parser "add_my_method :foo, :bar\nadd_my_method :baz"
1384
1216
 
@@ -1391,7 +1223,7 @@ end
1391
1223
 
1392
1224
  def test_parse_meta_method_unknown
1393
1225
  klass = RDoc::NormalClass.new 'Foo'
1394
- comment = "##\n# my method\n"
1226
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
1395
1227
 
1396
1228
  util_parser "add_my_method ('foo')"
1397
1229
 
@@ -1401,7 +1233,7 @@ end
1401
1233
 
1402
1234
  foo = klass.method_list.first
1403
1235
  assert_equal 'unknown', foo.name
1404
- assert_equal 'my method', foo.comment
1236
+ assert_equal 'my method', foo.comment.text
1405
1237
  assert_equal @top_level, foo.file
1406
1238
  end
1407
1239
 
@@ -1409,7 +1241,7 @@ end
1409
1241
  klass = RDoc::NormalClass.new 'Foo'
1410
1242
  klass.parent = @top_level
1411
1243
 
1412
- comment = "##\n# my method\n"
1244
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
1413
1245
 
1414
1246
  util_parser "def foo() :bar end"
1415
1247
 
@@ -1419,7 +1251,7 @@ end
1419
1251
 
1420
1252
  foo = klass.method_list.first
1421
1253
  assert_equal 'foo', foo.name
1422
- assert_equal 'my method', foo.comment
1254
+ assert_equal 'my method', foo.comment.text
1423
1255
  assert_equal @top_level, foo.file
1424
1256
  assert_equal 0, foo.offset
1425
1257
  assert_equal 1, foo.line
@@ -1468,7 +1300,7 @@ end
1468
1300
 
1469
1301
  tk = @parser.get_tk
1470
1302
 
1471
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, ''
1303
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
1472
1304
 
1473
1305
  assert klass.aliases.empty?
1474
1306
  end
@@ -1478,7 +1310,7 @@ end
1478
1310
 
1479
1311
  tk = @parser.get_tk
1480
1312
 
1481
- @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, ''
1313
+ @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
1482
1314
 
1483
1315
  klass = RDoc::TopLevel.find_class_named 'FalseClass'
1484
1316
 
@@ -1494,7 +1326,7 @@ end
1494
1326
 
1495
1327
  tk = @parser.get_tk
1496
1328
 
1497
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, ''
1329
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
1498
1330
 
1499
1331
  assert klass.method_list.empty?
1500
1332
  end
@@ -1504,7 +1336,7 @@ end
1504
1336
 
1505
1337
  tk = @parser.get_tk
1506
1338
 
1507
- @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, ''
1339
+ @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
1508
1340
 
1509
1341
  assert @top_level.method_list.empty?
1510
1342
  end
@@ -1517,7 +1349,7 @@ end
1517
1349
 
1518
1350
  tk = @parser.get_tk
1519
1351
 
1520
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, ''
1352
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
1521
1353
 
1522
1354
  assert_equal 1, klass.method_list.length
1523
1355
  end
@@ -1530,7 +1362,7 @@ end
1530
1362
 
1531
1363
  tk = @parser.get_tk
1532
1364
 
1533
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, ''
1365
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
1534
1366
 
1535
1367
  assert_equal 1, klass.method_list.length
1536
1368
  end
@@ -1543,7 +1375,7 @@ end
1543
1375
 
1544
1376
  tk = @parser.get_tk
1545
1377
 
1546
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, ''
1378
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
1547
1379
 
1548
1380
  assert_equal 1, klass.method_list.length
1549
1381
  end
@@ -1553,7 +1385,7 @@ end
1553
1385
 
1554
1386
  tk = @parser.get_tk
1555
1387
 
1556
- @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, ''
1388
+ @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
1557
1389
 
1558
1390
  klass = RDoc::TopLevel.find_class_named 'NilClass'
1559
1391
 
@@ -1569,7 +1401,7 @@ end
1569
1401
 
1570
1402
  tk = @parser.get_tk
1571
1403
 
1572
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, ''
1404
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
1573
1405
 
1574
1406
  foo = klass.method_list.first
1575
1407
  assert_equal '(arg1, arg2 = {})', foo.params
@@ -1584,7 +1416,7 @@ end
1584
1416
 
1585
1417
  tk = @parser.get_tk
1586
1418
 
1587
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, ''
1419
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
1588
1420
 
1589
1421
  foo = klass.method_list.first
1590
1422
  assert_equal '(arg1, arg2)', foo.params
@@ -1598,7 +1430,7 @@ end
1598
1430
 
1599
1431
  tk = @parser.get_tk
1600
1432
 
1601
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, ''
1433
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
1602
1434
 
1603
1435
  foo = klass.method_list.first
1604
1436
  assert_equal '(arg1, arg2, arg3)', foo.params
@@ -1609,7 +1441,7 @@ end
1609
1441
  klass.parent = @top_level
1610
1442
  klass.stop_doc
1611
1443
 
1612
- comment = "##\n# my method\n"
1444
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
1613
1445
 
1614
1446
  util_parser "def foo() :bar end"
1615
1447
 
@@ -1627,7 +1459,7 @@ end
1627
1459
 
1628
1460
  tk = @parser.get_tk
1629
1461
 
1630
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, ''
1462
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
1631
1463
 
1632
1464
  object = RDoc::TopLevel.find_class_named 'Object'
1633
1465
 
@@ -1643,7 +1475,7 @@ end
1643
1475
 
1644
1476
  tk = @parser.get_tk
1645
1477
 
1646
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, ''
1478
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
1647
1479
 
1648
1480
  object = RDoc::TopLevel.find_class_named 'Object'
1649
1481
 
@@ -1656,7 +1488,7 @@ end
1656
1488
 
1657
1489
  tk = @parser.get_tk
1658
1490
 
1659
- @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, ''
1491
+ @parser.parse_method @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
1660
1492
 
1661
1493
  klass = RDoc::TopLevel.find_class_named 'TrueClass'
1662
1494
 
@@ -1677,7 +1509,7 @@ end
1677
1509
 
1678
1510
  tk = @parser.get_tk
1679
1511
 
1680
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, ''
1512
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
1681
1513
 
1682
1514
  omega = klass.method_list.first
1683
1515
  assert_equal "def \317\211", omega.text
@@ -1695,7 +1527,7 @@ module Foo
1695
1527
  end
1696
1528
  CODE
1697
1529
 
1698
- @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
1530
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil
1699
1531
 
1700
1532
  foo = @top_level.modules.first
1701
1533
  assert_equal 'Foo', foo.full_name, 'module Foo'
@@ -1706,18 +1538,46 @@ end
1706
1538
  end
1707
1539
 
1708
1540
  def test_parse_statements_class_nested
1709
- comment = "##\n# my method\n"
1541
+ comment = RDoc::Comment.new "##\n# my method\n", @top_level
1710
1542
 
1711
- util_parser "module Foo\n#{comment}class Bar\nend\nend"
1543
+ util_parser "module Foo\n#{comment.text}class Bar\nend\nend"
1712
1544
 
1713
- @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
1545
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL
1714
1546
 
1715
1547
  foo = @top_level.modules.first
1716
1548
  assert_equal 'Foo', foo.full_name, 'module Foo'
1717
1549
 
1718
1550
  bar = foo.classes.first
1719
1551
  assert_equal 'Foo::Bar', bar.full_name, 'class Foo::Bar'
1720
- assert_equal 'my method', bar.comment
1552
+ assert_equal 'my method', bar.comment.text
1553
+ end
1554
+
1555
+ def test_parse_statements_def_percent_string_pound
1556
+ util_parser "class C\ndef a\n%r{#}\nend\ndef b() end\nend"
1557
+
1558
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL
1559
+
1560
+ x = @top_level.classes.first
1561
+
1562
+ assert_equal 2, x.method_list.length
1563
+ a = x.method_list.first
1564
+
1565
+ rt = RDoc::RubyToken
1566
+
1567
+ expected = [
1568
+ rt::TkCOMMENT .new( 0, 2, 1, "# File #{@filename}, line 2"),
1569
+ rt::TkNL .new( 0, 0, 0, "\n"),
1570
+ rt::TkSPACE .new( 0, 1, 1, ""),
1571
+ rt::TkDEF .new( 8, 2, 0, "def"),
1572
+ rt::TkSPACE .new(11, 2, 3, " "),
1573
+ rt::TkIDENTIFIER.new(12, 2, 4, "a"),
1574
+ rt::TkNL .new(13, 2, 5, "\n"),
1575
+ rt::TkDREGEXP .new(14, 3, 0, "%r{#}"),
1576
+ rt::TkNL .new(19, 3, 5, "\n"),
1577
+ rt::TkEND .new(20, 4, 0, "end"),
1578
+ ]
1579
+
1580
+ assert_equal expected, a.token_stream
1721
1581
  end
1722
1582
 
1723
1583
  def test_parse_statements_encoding
@@ -1738,8 +1598,8 @@ end
1738
1598
 
1739
1599
  foo = @top_level.classes.first.method_list.first
1740
1600
  assert_equal 'foo', foo.name
1741
- assert_equal 'this is my method', foo.comment
1742
- assert_equal Encoding::CP852, foo.comment.encoding
1601
+ assert_equal 'this is my method', foo.comment.text
1602
+ assert_equal Encoding::CP852, foo.comment.text.encoding
1743
1603
  end
1744
1604
 
1745
1605
  def test_parse_statements_identifier_meta_method
@@ -2220,7 +2080,7 @@ end
2220
2080
 
2221
2081
  tk = @parser.get_tk
2222
2082
 
2223
- @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, ''
2083
+ @parser.parse_method klass, RDoc::Parser::Ruby::NORMAL, tk, @comment
2224
2084
 
2225
2085
  foo = klass.method_list.first
2226
2086
  assert_equal 'nth(i)', foo.block_params
@@ -2255,7 +2115,7 @@ end
2255
2115
  def test_sanity_interpolation_curly
2256
2116
  util_parser '%{ #{} }'
2257
2117
 
2258
- assert_equal '%{ #{} }', @parser.get_tk.text
2118
+ assert_equal '%Q{ #{} }', @parser.get_tk.text
2259
2119
  assert_equal RDoc::RubyToken::TkNL, @parser.get_tk.class
2260
2120
  end
2261
2121
 
@@ -2312,11 +2172,11 @@ end
2312
2172
 
2313
2173
  foo = @top_level.classes.first
2314
2174
 
2315
- assert_equal 'Foo comment', foo.comment
2175
+ assert_equal 'Foo comment', foo.comment.text
2316
2176
 
2317
2177
  m = foo.method_list.first
2318
2178
 
2319
- assert_equal 'm comment', m.comment
2179
+ assert_equal 'm comment', m.comment.text
2320
2180
  end
2321
2181
 
2322
2182
  def test_scan_block_comment_nested # Issue #41
@@ -2338,12 +2198,12 @@ end
2338
2198
  foo = @top_level.modules.first
2339
2199
 
2340
2200
  assert_equal 'Foo', foo.full_name
2341
- assert_equal 'findmeindoc', foo.comment
2201
+ assert_equal 'findmeindoc', foo.comment.text
2342
2202
 
2343
2203
  bar = foo.classes.first
2344
2204
 
2345
2205
  assert_equal 'Foo::Bar', bar.full_name
2346
- assert_equal '', bar.comment
2206
+ assert_equal '', bar.comment.text
2347
2207
  end
2348
2208
 
2349
2209
  def test_scan_block_comment_notflush
@@ -2386,11 +2246,11 @@ end
2386
2246
  foo = @top_level.classes.first
2387
2247
 
2388
2248
  assert_equal "= DESCRIPTION\n\nThis is a simple test class\n\n= RUMPUS\n\nIs a silly word",
2389
- foo.comment
2249
+ foo.comment.text
2390
2250
 
2391
2251
  m = foo.method_list.first
2392
2252
 
2393
- assert_equal 'A nice girl', m.comment
2253
+ assert_equal 'A nice girl', m.comment.text
2394
2254
  end
2395
2255
 
2396
2256
  def test_scan_meta_method_block
@@ -2415,6 +2275,87 @@ class C
2415
2275
  assert_equal 2, @top_level.classes.first.method_list.length
2416
2276
  end
2417
2277
 
2278
+ def test_scan_markup_override
2279
+ content = <<-CONTENT
2280
+ # *awesome*
2281
+ class C
2282
+ # :markup: rd
2283
+ # ((*radical*))
2284
+ def m
2285
+ end
2286
+ end
2287
+ CONTENT
2288
+
2289
+ util_parser content
2290
+
2291
+ @parser.scan
2292
+
2293
+ c = @top_level.classes.first
2294
+
2295
+ assert_equal 'rdoc', c.comment.format
2296
+
2297
+ assert_equal 'rd', c.method_list.first.comment.format
2298
+ end
2299
+
2300
+ def test_scan_markup_first_comment
2301
+ content = <<-CONTENT
2302
+ # :markup: rd
2303
+
2304
+ # ((*awesome*))
2305
+ class C
2306
+ # ((*radical*))
2307
+ def m
2308
+ end
2309
+ end
2310
+ CONTENT
2311
+
2312
+ util_parser content
2313
+
2314
+ @parser.scan
2315
+
2316
+ c = @top_level.classes.first
2317
+
2318
+ assert_equal 'rd', c.comment.format
2319
+
2320
+ assert_equal 'rd', c.method_list.first.comment.format
2321
+ end
2322
+
2323
+ def test_scan_tomdoc_meta
2324
+ util_parser <<-RUBY
2325
+ # :markup: tomdoc
2326
+
2327
+ class C
2328
+
2329
+ # Signature
2330
+ #
2331
+ # find_by_<field>[_and_<field>...](args)
2332
+ #
2333
+ # field - A field name.
2334
+
2335
+ end
2336
+
2337
+ RUBY
2338
+
2339
+ @parser.scan
2340
+
2341
+ c = @top_level.classes.first
2342
+
2343
+ m = c.method_list.first
2344
+
2345
+ assert_equal "find_by_<field>[_and_<field>...]", m.name
2346
+ assert_equal "find_by_<field>[_and_<field>...](args)\n", m.call_seq
2347
+
2348
+ expected =
2349
+ @RM::Document.new(
2350
+ @RM::Heading.new(3, 'Signature'),
2351
+ @RM::List.new(:NOTE,
2352
+ @RM::ListItem.new('field',
2353
+ @RM::Paragraph.new('A field name.'))))
2354
+ expected.file = @top_level
2355
+
2356
+ assert_equal expected, m.comment.parse
2357
+ end
2358
+
2418
2359
  def test_stopdoc_after_comment
2419
2360
  util_parser <<-EOS
2420
2361
  module Bar
@@ -2433,11 +2374,11 @@ class C
2433
2374
 
2434
2375
  foo = @top_level.modules.first.modules.first
2435
2376
  assert_equal 'Foo', foo.name
2436
- assert_equal 'hello', foo.comment
2377
+ assert_equal 'hello', foo.comment.text
2437
2378
 
2438
2379
  baz = @top_level.modules.first.classes.first
2439
2380
  assert_equal 'Baz', baz.name
2440
- assert_equal 'there', baz.comment
2381
+ assert_equal 'there', baz.comment.text
2441
2382
  end
2442
2383
 
2443
2384
  def tk(klass, line, char, name, text)
@@ -2445,9 +2386,9 @@ class C
2445
2386
 
2446
2387
  token = if klass.instance_method(:initialize).arity == 3 then
2447
2388
  raise ArgumentError, "name not used for #{klass}" unless name.nil?
2448
- klass.new nil, line, char
2389
+ klass.new 0, line, char
2449
2390
  else
2450
- klass.new nil, line, char, name
2391
+ klass.new 0, line, char, name
2451
2392
  end
2452
2393
 
2453
2394
  token.set_text text