rdoc 4.0.1 → 4.1.0.preview.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +1 -3
  5. data/{DEVELOPERS.rdoc → CONTRIBUTING.rdoc} +28 -3
  6. data/ExampleMarkdown.md +37 -0
  7. data/ExampleRDoc.rdoc +208 -0
  8. data/History.rdoc +81 -0
  9. data/Manifest.txt +11 -2
  10. data/README.rdoc +5 -5
  11. data/Rakefile +34 -4
  12. data/lib/rdoc.rb +4 -3
  13. data/lib/rdoc/any_method.rb +48 -4
  14. data/lib/rdoc/class_module.rb +16 -2
  15. data/lib/rdoc/code_object.rb +85 -24
  16. data/lib/rdoc/comment.rb +0 -3
  17. data/lib/rdoc/constant.rb +9 -1
  18. data/lib/rdoc/context.rb +20 -2
  19. data/lib/rdoc/cross_reference.rb +1 -1
  20. data/lib/rdoc/extend.rb +4 -112
  21. data/lib/rdoc/generator/darkfish.rb +46 -7
  22. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +4 -4
  23. data/lib/rdoc/generator/template/darkfish/_head.rhtml +14 -8
  24. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +4 -3
  25. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +3 -3
  26. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +3 -4
  27. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +4 -3
  28. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +3 -4
  29. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +3 -3
  30. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +4 -4
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +9 -5
  32. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -3
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +12 -7
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +5 -4
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +6 -7
  37. data/lib/rdoc/generator/template/darkfish/class.rhtml +36 -41
  38. data/lib/rdoc/generator/template/darkfish/fonts.css +167 -0
  39. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  40. data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  41. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  42. data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  43. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  44. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  45. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  46. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  47. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  48. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  49. data/lib/rdoc/generator/template/darkfish/index.rhtml +11 -7
  50. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +0 -15
  51. data/lib/rdoc/generator/template/darkfish/js/search.js +12 -4
  52. data/lib/rdoc/generator/template/darkfish/page.rhtml +9 -9
  53. data/lib/rdoc/generator/template/darkfish/rdoc.css +226 -241
  54. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +5 -5
  55. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +13 -6
  56. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +17 -14
  57. data/lib/rdoc/include.rb +4 -114
  58. data/lib/rdoc/known_classes.rb +1 -0
  59. data/lib/rdoc/markdown.kpeg +126 -117
  60. data/lib/rdoc/markdown.rb +404 -389
  61. data/lib/rdoc/markdown/literals_1_8.kpeg +1 -1
  62. data/lib/rdoc/markdown/literals_1_8.rb +15 -12
  63. data/lib/rdoc/markdown/literals_1_9.kpeg +1 -1
  64. data/lib/rdoc/markdown/literals_1_9.rb +15 -12
  65. data/lib/rdoc/markup.rb +10 -13
  66. data/lib/rdoc/markup/attribute_manager.rb +3 -2
  67. data/lib/rdoc/markup/formatter.rb +3 -3
  68. data/lib/rdoc/markup/heading.rb +13 -0
  69. data/lib/rdoc/markup/parser.rb +10 -3
  70. data/lib/rdoc/markup/pre_process.rb +1 -1
  71. data/lib/rdoc/markup/to_html.rb +46 -31
  72. data/lib/rdoc/markup/to_html_crossref.rb +3 -0
  73. data/lib/rdoc/markup/to_joined_paragraph.rb +1 -1
  74. data/lib/rdoc/markup/to_markdown.rb +7 -5
  75. data/lib/rdoc/markup/verbatim.rb +1 -1
  76. data/lib/rdoc/method_attr.rb +13 -1
  77. data/lib/rdoc/mixin.rb +120 -0
  78. data/lib/rdoc/normal_class.rb +4 -0
  79. data/lib/rdoc/normal_module.rb +4 -0
  80. data/lib/rdoc/options.rb +42 -8
  81. data/lib/rdoc/parser.rb +4 -2
  82. data/lib/rdoc/parser/c.rb +13 -7
  83. data/lib/rdoc/parser/ruby.rb +683 -480
  84. data/lib/rdoc/rdoc.rb +4 -3
  85. data/lib/rdoc/ri/driver.rb +174 -103
  86. data/lib/rdoc/ri/paths.rb +6 -6
  87. data/lib/rdoc/ruby_lex.rb +125 -102
  88. data/lib/rdoc/ruby_token.rb +41 -40
  89. data/lib/rdoc/servlet.rb +16 -6
  90. data/lib/rdoc/stats.rb +61 -48
  91. data/lib/rdoc/store.rb +5 -3
  92. data/lib/rdoc/test_case.rb +39 -0
  93. data/lib/rdoc/tom_doc.rb +28 -4
  94. data/lib/rdoc/top_level.rb +2 -2
  95. data/test/test_rdoc_any_method.rb +104 -1
  96. data/test/test_rdoc_class_module.rb +9 -15
  97. data/test/test_rdoc_code_object.rb +133 -8
  98. data/test/test_rdoc_context.rb +17 -0
  99. data/test/test_rdoc_context_section.rb +0 -7
  100. data/test/test_rdoc_cross_reference.rb +4 -3
  101. data/test/test_rdoc_generator_darkfish.rb +61 -19
  102. data/test/test_rdoc_generator_json_index.rb +0 -11
  103. data/test/test_rdoc_generator_ri.rb +0 -8
  104. data/test/test_rdoc_markdown.rb +15 -12
  105. data/test/test_rdoc_markdown_test.rb +0 -7
  106. data/test/test_rdoc_markup_attribute_manager.rb +121 -0
  107. data/test/test_rdoc_markup_document.rb +0 -7
  108. data/test/test_rdoc_markup_formatter.rb +29 -3
  109. data/test/test_rdoc_markup_heading.rb +9 -0
  110. data/test/test_rdoc_markup_parser.rb +0 -7
  111. data/test/test_rdoc_markup_pre_process.rb +15 -3
  112. data/test/test_rdoc_markup_raw.rb +0 -7
  113. data/test/test_rdoc_markup_to_html.rb +50 -8
  114. data/test/test_rdoc_markup_to_html_crossref.rb +7 -0
  115. data/test/test_rdoc_markup_to_html_snippet.rb +4 -4
  116. data/test/test_rdoc_markup_to_markdown.rb +6 -0
  117. data/test/test_rdoc_method_attr.rb +8 -0
  118. data/test/test_rdoc_normal_class.rb +5 -0
  119. data/test/test_rdoc_normal_module.rb +5 -0
  120. data/test/test_rdoc_options.rb +61 -22
  121. data/test/test_rdoc_parser.rb +10 -0
  122. data/test/test_rdoc_parser_c.rb +17 -5
  123. data/test/test_rdoc_parser_changelog.rb +0 -7
  124. data/test/test_rdoc_parser_rd.rb +0 -7
  125. data/test/test_rdoc_parser_ruby.rb +305 -28
  126. data/test/test_rdoc_rd_block_parser.rb +0 -8
  127. data/test/test_rdoc_rd_inline_parser.rb +0 -1
  128. data/test/test_rdoc_rdoc.rb +27 -1
  129. data/test/test_rdoc_ri_driver.rb +19 -7
  130. data/test/test_rdoc_ruby_lex.rb +116 -9
  131. data/test/test_rdoc_rubygems_hook.rb +1 -1
  132. data/test/test_rdoc_servlet.rb +44 -6
  133. data/test/test_rdoc_stats.rb +161 -141
  134. data/test/test_rdoc_store.rb +11 -19
  135. data/test/test_rdoc_text.rb +0 -7
  136. data/test/test_rdoc_tom_doc.rb +44 -16
  137. data/test/xref_test_case.rb +2 -0
  138. metadata +28 -27
  139. metadata.gz.sig +0 -0
  140. data/test/test_attribute_manager.rb +0 -120
@@ -276,50 +276,50 @@ module RDoc::RubyToken
276
276
  end
277
277
 
278
278
  TokenDefinitions = [
279
- [:TkCLASS, TkKW, "class", EXPR_CLASS],
280
- [:TkMODULE, TkKW, "module", EXPR_BEG],
281
- [:TkDEF, TkKW, "def", EXPR_FNAME],
282
- [:TkUNDEF, TkKW, "undef", EXPR_FNAME],
283
- [:TkBEGIN, TkKW, "begin", EXPR_BEG],
284
- [:TkRESCUE, TkKW, "rescue", EXPR_MID],
285
- [:TkENSURE, TkKW, "ensure", EXPR_BEG],
286
- [:TkEND, TkKW, "end", EXPR_END],
287
- [:TkIF, TkKW, "if", EXPR_BEG, :TkIF_MOD],
288
- [:TkUNLESS, TkKW, "unless", EXPR_BEG, :TkUNLESS_MOD],
289
- [:TkTHEN, TkKW, "then", EXPR_BEG],
290
- [:TkELSIF, TkKW, "elsif", EXPR_BEG],
291
- [:TkELSE, TkKW, "else", EXPR_BEG],
292
- [:TkCASE, TkKW, "case", EXPR_BEG],
293
- [:TkWHEN, TkKW, "when", EXPR_BEG],
294
- [:TkWHILE, TkKW, "while", EXPR_BEG, :TkWHILE_MOD],
295
- [:TkUNTIL, TkKW, "until", EXPR_BEG, :TkUNTIL_MOD],
296
- [:TkFOR, TkKW, "for", EXPR_BEG],
297
- [:TkBREAK, TkKW, "break", EXPR_MID],
298
- [:TkNEXT, TkKW, "next", EXPR_END],
299
- [:TkREDO, TkKW, "redo", EXPR_END],
300
- [:TkRETRY, TkKW, "retry", EXPR_END],
301
- [:TkIN, TkKW, "in", EXPR_BEG],
302
- [:TkDO, TkKW, "do", EXPR_BEG],
303
- [:TkRETURN, TkKW, "return", EXPR_MID],
304
- [:TkYIELD, TkKW, "yield", EXPR_END],
305
- [:TkSUPER, TkKW, "super", EXPR_END],
306
- [:TkSELF, TkKW, "self", EXPR_END],
307
- [:TkNIL, TkKW, "nil", EXPR_END],
308
- [:TkTRUE, TkKW, "true", EXPR_END],
309
- [:TkFALSE, TkKW, "false", EXPR_END],
310
- [:TkAND, TkKW, "and", EXPR_BEG],
311
- [:TkOR, TkKW, "or", EXPR_BEG],
312
- [:TkNOT, TkKW, "not", EXPR_BEG],
279
+ [:TkCLASS, TkKW, "class", :EXPR_CLASS],
280
+ [:TkMODULE, TkKW, "module", :EXPR_BEG],
281
+ [:TkDEF, TkKW, "def", :EXPR_FNAME],
282
+ [:TkUNDEF, TkKW, "undef", :EXPR_FNAME],
283
+ [:TkBEGIN, TkKW, "begin", :EXPR_BEG],
284
+ [:TkRESCUE, TkKW, "rescue", :EXPR_MID],
285
+ [:TkENSURE, TkKW, "ensure", :EXPR_BEG],
286
+ [:TkEND, TkKW, "end", :EXPR_END],
287
+ [:TkIF, TkKW, "if", :EXPR_BEG, :TkIF_MOD],
288
+ [:TkUNLESS, TkKW, "unless", :EXPR_BEG, :TkUNLESS_MOD],
289
+ [:TkTHEN, TkKW, "then", :EXPR_BEG],
290
+ [:TkELSIF, TkKW, "elsif", :EXPR_BEG],
291
+ [:TkELSE, TkKW, "else", :EXPR_BEG],
292
+ [:TkCASE, TkKW, "case", :EXPR_BEG],
293
+ [:TkWHEN, TkKW, "when", :EXPR_BEG],
294
+ [:TkWHILE, TkKW, "while", :EXPR_BEG, :TkWHILE_MOD],
295
+ [:TkUNTIL, TkKW, "until", :EXPR_BEG, :TkUNTIL_MOD],
296
+ [:TkFOR, TkKW, "for", :EXPR_BEG],
297
+ [:TkBREAK, TkKW, "break", :EXPR_MID],
298
+ [:TkNEXT, TkKW, "next", :EXPR_END],
299
+ [:TkREDO, TkKW, "redo", :EXPR_END],
300
+ [:TkRETRY, TkKW, "retry", :EXPR_END],
301
+ [:TkIN, TkKW, "in", :EXPR_BEG],
302
+ [:TkDO, TkKW, "do", :EXPR_BEG],
303
+ [:TkRETURN, TkKW, "return", :EXPR_MID],
304
+ [:TkYIELD, TkKW, "yield", :EXPR_END],
305
+ [:TkSUPER, TkKW, "super", :EXPR_END],
306
+ [:TkSELF, TkKW, "self", :EXPR_END],
307
+ [:TkNIL, TkKW, "nil", :EXPR_END],
308
+ [:TkTRUE, TkKW, "true", :EXPR_END],
309
+ [:TkFALSE, TkKW, "false", :EXPR_END],
310
+ [:TkAND, TkKW, "and", :EXPR_BEG],
311
+ [:TkOR, TkKW, "or", :EXPR_BEG],
312
+ [:TkNOT, TkKW, "not", :EXPR_BEG],
313
313
  [:TkIF_MOD, TkKW],
314
314
  [:TkUNLESS_MOD, TkKW],
315
315
  [:TkWHILE_MOD, TkKW],
316
316
  [:TkUNTIL_MOD, TkKW],
317
- [:TkALIAS, TkKW, "alias", EXPR_FNAME],
318
- [:TkDEFINED, TkKW, "defined?", EXPR_END],
319
- [:TklBEGIN, TkKW, "BEGIN", EXPR_END],
320
- [:TklEND, TkKW, "END", EXPR_END],
321
- [:Tk__LINE__, TkKW, "__LINE__", EXPR_END],
322
- [:Tk__FILE__, TkKW, "__FILE__", EXPR_END],
317
+ [:TkALIAS, TkKW, "alias", :EXPR_FNAME],
318
+ [:TkDEFINED, TkKW, "defined?", :EXPR_END],
319
+ [:TklBEGIN, TkKW, "BEGIN", :EXPR_END],
320
+ [:TklEND, TkKW, "END", :EXPR_END],
321
+ [:Tk__LINE__, TkKW, "__LINE__", :EXPR_END],
322
+ [:Tk__FILE__, TkKW, "__FILE__", :EXPR_END],
323
323
 
324
324
  [:TkIDENTIFIER, TkId],
325
325
  [:TkFID, TkId],
@@ -335,6 +335,7 @@ module RDoc::RubyToken
335
335
  [:TkXSTRING, TkVal],
336
336
  [:TkREGEXP, TkVal],
337
337
  [:TkSYMBOL, TkVal],
338
+ [:TkCHAR, TkVal],
338
339
 
339
340
  [:TkDSTRING, TkNode],
340
341
  [:TkDXSTRING, TkNode],
@@ -124,6 +124,10 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
124
124
  else
125
125
  show_documentation req, res
126
126
  end
127
+ rescue WEBrick::HTTPStatus::NotFound => e
128
+ generator = generator_for RDoc::Store.new
129
+
130
+ not_found generator, req, res, e.message
127
131
  rescue WEBrick::HTTPStatus::Status
128
132
  raise
129
133
  rescue => e
@@ -300,8 +304,9 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
300
304
  ##
301
305
  # Returns a 404 page built by +generator+ for +req+ on +res+.
302
306
 
303
- def not_found generator, req, res
304
- res.body = generator.generate_servlet_not_found req.path
307
+ def not_found generator, req, res, message = nil
308
+ message ||= "The page <kbd>#{ERB::Util.h req.path}</kbd> was not found"
309
+ res.body = generator.generate_servlet_not_found message
305
310
  res.status = 404
306
311
  end
307
312
 
@@ -419,11 +424,16 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
419
424
  source_name == dir[%r%/([^/]*)/ri$%, 1]
420
425
  end
421
426
 
422
- raise RDoc::Error,
423
- "could not find ri documentation for #{source_name}" unless
424
- ri_dir
427
+ raise WEBrick::HTTPStatus::NotFound,
428
+ "Could not find gem \"#{source_name}\". Are you sure you installed it?" unless ri_dir
429
+
430
+ store = RDoc::Store.new ri_dir, type
431
+
432
+ return store if File.exist? store.cache_path
433
+
434
+ raise WEBrick::HTTPStatus::NotFound,
435
+ "Could not find documentation for \"#{source_name}\". Please run `gem rdoc --ri gem_name`"
425
436
 
426
- RDoc::Store.new ri_dir, type
427
437
  end
428
438
  end
429
439
 
@@ -187,12 +187,12 @@ class RDoc::Stats
187
187
  # A report that says you did a great job!
188
188
 
189
189
  def great_job
190
- report = []
191
- report << '100% documentation!'
192
- report << nil
193
- report << 'Great Job!'
190
+ report = RDoc::Markup::Document.new
191
+
192
+ report << RDoc::Markup::Paragraph.new('100% documentation!')
193
+ report << RDoc::Markup::Paragraph.new('Great Job!')
194
194
 
195
- report.join "\n"
195
+ report
196
196
  end
197
197
 
198
198
  ##
@@ -217,8 +217,6 @@ class RDoc::Stats
217
217
  extend RDoc::Text
218
218
  end
219
219
 
220
- report = []
221
-
222
220
  if @coverage_level.zero? then
223
221
  calculate
224
222
 
@@ -227,14 +225,20 @@ class RDoc::Stats
227
225
 
228
226
  ucm = @store.unique_classes_and_modules
229
227
 
228
+ report = RDoc::Markup::Document.new
229
+ report << RDoc::Markup::Paragraph.new('The following items are not documented:')
230
+ report << RDoc::Markup::BlankLine.new
231
+
230
232
  ucm.sort.each do |cm|
231
- report << report_class_module(cm) {
233
+ body = report_class_module(cm) {
232
234
  [
233
235
  report_constants(cm),
234
236
  report_attributes(cm),
235
237
  report_methods(cm),
236
238
  ].compact
237
239
  }
240
+
241
+ report << body if body
238
242
  end
239
243
 
240
244
  if @coverage_level > 0 then
@@ -243,10 +247,7 @@ class RDoc::Stats
243
247
  return great_job if @num_items == @doc_items
244
248
  end
245
249
 
246
- report.unshift nil
247
- report.unshift 'The following items are not documented:'
248
-
249
- report.join "\n"
250
+ report
250
251
  end
251
252
 
252
253
  ##
@@ -260,7 +261,8 @@ class RDoc::Stats
260
261
  cm.each_attribute do |attr|
261
262
  next if attr.documented?
262
263
  line = attr.line ? ":#{attr.line}" : nil
263
- report << " #{attr.definition} :#{attr.name} # in file #{attr.file.full_name}#{line}"
264
+ report << " #{attr.definition} :#{attr.name} # in file #{attr.file.full_name}#{line}\n"
265
+ report << "\n"
264
266
  end
265
267
 
266
268
  report
@@ -273,38 +275,47 @@ class RDoc::Stats
273
275
  return if cm.fully_documented? and @coverage_level.zero?
274
276
  return unless cm.display?
275
277
 
276
- report = []
278
+ report = RDoc::Markup::Document.new
277
279
 
278
280
  if cm.in_files.empty? then
279
- report << "# #{cm.definition} is referenced but empty."
280
- report << "#"
281
- report << "# It probably came from another project. I'm sorry I'm holding it against you."
282
- report << nil
281
+ report << RDoc::Markup::Paragraph.new("#{cm.definition} is referenced but empty.")
282
+ report << RDoc::Markup::Paragraph.new("It probably came from another project. I'm sorry I'm holding it against you.")
283
283
 
284
284
  return report
285
285
  elsif cm.documented? then
286
286
  documented = true
287
- report << "#{cm.definition} # is documented"
287
+ klass = RDoc::Markup::Verbatim.new("#{cm.definition} # is documented\n")
288
288
  else
289
- report << '# in files:'
289
+ report << RDoc::Markup::Paragraph.new('In files:')
290
+
291
+ list = RDoc::Markup::List.new :BULLET
290
292
 
291
293
  cm.in_files.each do |file|
292
- report << "# #{file.full_name}"
294
+ para = RDoc::Markup::Paragraph.new file.full_name
295
+ list << RDoc::Markup::ListItem.new(nil, para)
293
296
  end
294
297
 
295
- report << nil
298
+ report << list
299
+ report << RDoc::Markup::BlankLine.new
296
300
 
297
- report << "#{cm.definition}"
301
+ klass = RDoc::Markup::Verbatim.new("#{cm.definition}\n")
298
302
  end
299
303
 
304
+ klass << "\n"
305
+
300
306
  body = yield.flatten # HACK remove #flatten
301
307
 
302
- return if body.empty? and documented
308
+ if body.empty? then
309
+ return if documented
310
+
311
+ klass.parts.pop
312
+ else
313
+ klass.parts.concat body
314
+ end
303
315
 
304
- report << nil << body unless body.empty?
316
+ klass << "end\n"
305
317
 
306
- report << 'end'
307
- report << nil
318
+ report << klass
308
319
 
309
320
  report
310
321
  end
@@ -323,8 +334,9 @@ class RDoc::Stats
323
334
  next if constant.documented? || constant.is_alias_for
324
335
 
325
336
  line = constant.line ? ":#{constant.line}" : line
326
- report << " # in file #{constant.file.full_name}#{line}"
327
- report << " #{constant.name} = nil"
337
+ report << " # in file #{constant.file.full_name}#{line}\n"
338
+ report << " #{constant.name} = nil\n"
339
+ report << "\n"
328
340
  end
329
341
 
330
342
  report
@@ -350,7 +362,7 @@ class RDoc::Stats
350
362
  @undoc_params += undoc.length
351
363
 
352
364
  undoc = undoc.map do |param| "+#{param}+" end
353
- param_report = " # #{undoc.join ', '} is not documented"
365
+ param_report = " # #{undoc.join ', '} is not documented\n"
354
366
  end
355
367
  end
356
368
 
@@ -359,10 +371,10 @@ class RDoc::Stats
359
371
  line = method.line ? ":#{method.line}" : nil
360
372
  scope = method.singleton ? 'self.' : nil
361
373
 
362
- report << " # in file #{method.file.full_name}#{line}"
374
+ report << " # in file #{method.file.full_name}#{line}\n"
363
375
  report << param_report if param_report
364
- report << " def #{scope}#{method.name}#{method.params}; end"
365
- report << nil
376
+ report << " def #{scope}#{method.name}#{method.params}; end\n"
377
+ report << "\n"
366
378
  end
367
379
 
368
380
  report
@@ -385,35 +397,36 @@ class RDoc::Stats
385
397
  @undoc_params,
386
398
  ].max.to_s.length
387
399
 
388
- report = []
389
- report << 'Files: %*d' % [num_width, @num_files]
400
+ report = RDoc::Markup::Verbatim.new
401
+
402
+ report << "Files: %*d\n" % [num_width, @num_files]
390
403
 
391
- report << nil
404
+ report << "\n"
392
405
 
393
- report << 'Classes: %*d (%*d undocumented)' % [
406
+ report << "Classes: %*d (%*d undocumented)\n" % [
394
407
  num_width, @num_classes, undoc_width, @undoc_classes]
395
- report << 'Modules: %*d (%*d undocumented)' % [
408
+ report << "Modules: %*d (%*d undocumented)\n" % [
396
409
  num_width, @num_modules, undoc_width, @undoc_modules]
397
- report << 'Constants: %*d (%*d undocumented)' % [
410
+ report << "Constants: %*d (%*d undocumented)\n" % [
398
411
  num_width, @num_constants, undoc_width, @undoc_constants]
399
- report << 'Attributes: %*d (%*d undocumented)' % [
412
+ report << "Attributes: %*d (%*d undocumented)\n" % [
400
413
  num_width, @num_attributes, undoc_width, @undoc_attributes]
401
- report << 'Methods: %*d (%*d undocumented)' % [
414
+ report << "Methods: %*d (%*d undocumented)\n" % [
402
415
  num_width, @num_methods, undoc_width, @undoc_methods]
403
- report << 'Parameters: %*d (%*d undocumented)' % [
416
+ report << "Parameters: %*d (%*d undocumented)\n" % [
404
417
  num_width, @num_params, undoc_width, @undoc_params] if
405
418
  @coverage_level > 0
406
419
 
407
- report << nil
420
+ report << "\n"
408
421
 
409
- report << 'Total: %*d (%*d undocumented)' % [
422
+ report << "Total: %*d (%*d undocumented)\n" % [
410
423
  num_width, @num_items, undoc_width, @undoc_items]
411
424
 
412
- report << '%6.2f%% documented' % percent_doc
413
- report << nil
414
- report << 'Elapsed: %0.1fs' % (Time.now - @start)
425
+ report << "%6.2f%% documented\n" % percent_doc
426
+ report << "\n"
427
+ report << "Elapsed: %0.1fs\n" % (Time.now - @start)
415
428
 
416
- report.join "\n"
429
+ RDoc::Markup::Document.new report
417
430
  end
418
431
 
419
432
  ##
@@ -305,8 +305,10 @@ class RDoc::Store
305
305
  # cache included modules before they are removed from the documentation
306
306
  all_classes_and_modules.each { |cm| cm.ancestors }
307
307
 
308
- remove_nodoc @classes_hash
309
- remove_nodoc @modules_hash
308
+ unless min_visibility == :nodoc then
309
+ remove_nodoc @classes_hash
310
+ remove_nodoc @modules_hash
311
+ end
310
312
 
311
313
  @unique_classes = find_unique @classes_hash
312
314
  @unique_modules = find_unique @modules_hash
@@ -661,7 +663,7 @@ class RDoc::Store
661
663
  end
662
664
 
663
665
  ##
664
- # Converts the variable => ClassModule map +variables+ from a C parser into
666
+ # Converts the variable => ClassModule map +variables+ from a C parser into
665
667
  # a variable => class name map.
666
668
 
667
669
  def make_variable_map variables
@@ -1,4 +1,11 @@
1
1
  require 'rubygems'
2
+
3
+ begin
4
+ gem 'minitest', '~> 4.0' unless defined?(Test::Unit)
5
+ rescue NoMethodError
6
+ # for ruby tests
7
+ end
8
+
2
9
  require 'minitest/autorun'
3
10
  require 'minitest/benchmark' if ENV['BENCHMARK']
4
11
 
@@ -45,6 +52,7 @@ class RDoc::TestCase < MiniTest::Unit::TestCase
45
52
 
46
53
  @rdoc = RDoc::RDoc.new
47
54
  @rdoc.store = @store
55
+ @rdoc.options = RDoc::Options.new
48
56
 
49
57
  g = Object.new
50
58
  def g.class_dir() end
@@ -52,6 +60,27 @@ class RDoc::TestCase < MiniTest::Unit::TestCase
52
60
  @rdoc.generator = g
53
61
  end
54
62
 
63
+ ##
64
+ # Asserts +path+ is a file
65
+
66
+ def assert_file path
67
+ assert File.file?(path), "#{path} is not a file"
68
+ end
69
+
70
+ ##
71
+ # Asserts +path+ is a directory
72
+
73
+ def assert_directory path
74
+ assert File.directory?(path), "#{path} is not a directory"
75
+ end
76
+
77
+ ##
78
+ # Refutes +path+ exists
79
+
80
+ def refute_file path
81
+ refute File.exist?(path), "#{path} exists"
82
+ end
83
+
55
84
  ##
56
85
  # Shortcut for RDoc::Markup::BlankLine.new
57
86
 
@@ -109,6 +138,16 @@ class RDoc::TestCase < MiniTest::Unit::TestCase
109
138
  @RM::List.new type, *items
110
139
  end
111
140
 
141
+ ##
142
+ # Enables pretty-print output
143
+
144
+ def mu_pp obj # :nodoc:
145
+ s = ''
146
+ s = PP.pp obj, s
147
+ s = s.force_encoding Encoding.default_external if defined? Encoding
148
+ s.chomp
149
+ end
150
+
112
151
  ##
113
152
  # Shortcut for RDoc::Markup::Paragraph.new with +contents+
114
153
 
@@ -129,7 +129,8 @@ class RDoc::TomDoc < RDoc::Markup::Parser
129
129
  def initialize
130
130
  super
131
131
 
132
- @section = nil
132
+ @section = nil
133
+ @seen_returns = false
133
134
  end
134
135
 
135
136
  # Internal: Builds a heading from the token stream
@@ -147,7 +148,7 @@ class RDoc::TomDoc < RDoc::Markup::Parser
147
148
  end
148
149
 
149
150
  # Internal: Builds a verbatim from the token stream. A verbatim in the
150
- # Examples section will be marked as in ruby format.
151
+ # Examples section will be marked as in Ruby format.
151
152
  #
152
153
  # margin - The indentation from the margin for lines that belong to this
153
154
  # verbatim section.
@@ -176,9 +177,17 @@ class RDoc::TomDoc < RDoc::Markup::Parser
176
177
  until @tokens.empty? do
177
178
  type, data, = get
178
179
 
179
- if type == :TEXT then
180
+ case type
181
+ when :TEXT then
182
+ @section = 'Returns' if data =~ /\AReturns/
183
+
180
184
  paragraph << data
181
- skip :NEWLINE
185
+ when :NEWLINE then
186
+ if :TEXT == peek_token[0] then
187
+ paragraph << ' '
188
+ else
189
+ break
190
+ end
182
191
  else
183
192
  unget
184
193
  break
@@ -190,6 +199,21 @@ class RDoc::TomDoc < RDoc::Markup::Parser
190
199
  paragraph
191
200
  end
192
201
 
202
+ ##
203
+ # Detects a section change to "Returns" and adds a heading
204
+
205
+ def parse_text parent, indent # :nodoc:
206
+ paragraph = build_paragraph indent
207
+
208
+ if false == @seen_returns and 'Returns' == @section then
209
+ @seen_returns = true
210
+ parent << RDoc::Markup::Heading.new(3, 'Returns')
211
+ parent << RDoc::Markup::BlankLine.new
212
+ end
213
+
214
+ parent << paragraph
215
+ end
216
+
193
217
  # Internal: Turns text into an Array of tokens
194
218
  #
195
219
  # text - A String containing TomDoc-format text.