rdoc 5.1.0 → 6.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.rdoc +5 -6
  3. data/ExampleMarkdown.md +2 -0
  4. data/ExampleRDoc.rdoc +2 -0
  5. data/History.rdoc +68 -66
  6. data/LEGAL.rdoc +1 -1
  7. data/LICENSE.rdoc +2 -0
  8. data/README.rdoc +18 -6
  9. data/RI.md +842 -0
  10. data/TODO.rdoc +8 -7
  11. data/exe/rdoc +0 -1
  12. data/lib/rdoc/{alias.rb → code_object/alias.rb} +4 -12
  13. data/lib/rdoc/{anon_class.rb → code_object/anon_class.rb} +1 -2
  14. data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +83 -26
  15. data/lib/rdoc/{attr.rb → code_object/attr.rb} +5 -9
  16. data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +112 -24
  17. data/lib/rdoc/{constant.rb → code_object/constant.rb} +4 -5
  18. data/lib/rdoc/{context → code_object/context}/section.rb +13 -83
  19. data/lib/rdoc/{context.rb → code_object/context.rb} +69 -70
  20. data/lib/rdoc/{extend.rb → code_object/extend.rb} +1 -2
  21. data/lib/rdoc/{ghost_method.rb → code_object/ghost_method.rb} +1 -2
  22. data/lib/rdoc/{include.rb → code_object/include.rb} +1 -2
  23. data/lib/rdoc/{meta_method.rb → code_object/meta_method.rb} +1 -2
  24. data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +22 -31
  25. data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +1 -2
  26. data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +4 -5
  27. data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +2 -3
  28. data/lib/rdoc/{require.rb → code_object/require.rb} +2 -3
  29. data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +6 -2
  30. data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +22 -32
  31. data/lib/rdoc/code_object.rb +8 -41
  32. data/lib/rdoc/code_objects.rb +2 -3
  33. data/lib/rdoc/comment.rb +48 -41
  34. data/lib/rdoc/cross_reference.rb +77 -33
  35. data/lib/rdoc/encoding.rb +50 -38
  36. data/lib/rdoc/erb_partial.rb +2 -3
  37. data/lib/rdoc/erbio.rb +4 -5
  38. data/lib/rdoc/generator/darkfish.rb +178 -125
  39. data/lib/rdoc/generator/json_index.rb +9 -22
  40. data/lib/rdoc/generator/markup.rb +6 -17
  41. data/lib/rdoc/generator/pot/message_extractor.rb +4 -4
  42. data/lib/rdoc/generator/pot/po.rb +3 -3
  43. data/lib/rdoc/generator/pot/po_entry.rb +12 -12
  44. data/lib/rdoc/generator/pot.rb +4 -8
  45. data/lib/rdoc/generator/ri.rb +1 -2
  46. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
  47. data/lib/rdoc/generator/template/darkfish/_head.rhtml +35 -12
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -5
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
  52. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +19 -10
  53. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +26 -6
  54. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -9
  55. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -1
  56. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  57. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +27 -6
  58. data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  59. data/lib/rdoc/generator/template/darkfish/class.rhtml +125 -78
  60. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +430 -339
  61. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  62. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  63. data/lib/rdoc/generator/template/darkfish/index.rhtml +13 -13
  64. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -92
  65. data/lib/rdoc/generator/template/darkfish/js/search.js +35 -34
  66. data/lib/rdoc/generator/template/darkfish/page.rhtml +5 -5
  67. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +10 -8
  68. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +20 -18
  69. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +32 -20
  70. data/lib/rdoc/generator/template/json_index/js/navigation.js +12 -49
  71. data/lib/rdoc/generator/template/json_index/js/searcher.js +6 -6
  72. data/lib/rdoc/generator.rb +6 -6
  73. data/lib/rdoc/i18n/locale.rb +1 -1
  74. data/lib/rdoc/i18n/text.rb +5 -5
  75. data/lib/rdoc/i18n.rb +4 -4
  76. data/lib/rdoc/known_classes.rb +6 -5
  77. data/lib/rdoc/markdown/entities.rb +1 -2
  78. data/lib/rdoc/markdown/literals.kpeg +1 -2
  79. data/lib/rdoc/markdown/literals.rb +99 -50
  80. data/lib/rdoc/markdown.kpeg +115 -58
  81. data/lib/rdoc/markdown.rb +1584 -902
  82. data/lib/rdoc/markup/attr_changer.rb +1 -2
  83. data/lib/rdoc/markup/attr_span.rb +9 -4
  84. data/lib/rdoc/markup/attribute_manager.rb +118 -57
  85. data/lib/rdoc/markup/attributes.rb +7 -8
  86. data/lib/rdoc/markup/blank_line.rb +1 -2
  87. data/lib/rdoc/markup/block_quote.rb +1 -2
  88. data/lib/rdoc/markup/document.rb +1 -2
  89. data/lib/rdoc/markup/formatter.rb +44 -37
  90. data/lib/rdoc/markup/hard_break.rb +1 -2
  91. data/lib/rdoc/markup/heading.rb +11 -6
  92. data/lib/rdoc/markup/include.rb +1 -2
  93. data/lib/rdoc/markup/indented_paragraph.rb +1 -2
  94. data/lib/rdoc/markup/list.rb +1 -2
  95. data/lib/rdoc/markup/list_item.rb +1 -2
  96. data/lib/rdoc/markup/paragraph.rb +1 -2
  97. data/lib/rdoc/markup/parser.rb +90 -48
  98. data/lib/rdoc/markup/pre_process.rb +38 -11
  99. data/lib/rdoc/markup/raw.rb +1 -2
  100. data/lib/rdoc/markup/regexp_handling.rb +40 -0
  101. data/lib/rdoc/markup/rule.rb +1 -2
  102. data/lib/rdoc/markup/table.rb +56 -0
  103. data/lib/rdoc/markup/to_ansi.rb +1 -2
  104. data/lib/rdoc/markup/to_bs.rb +30 -5
  105. data/lib/rdoc/markup/to_html.rb +95 -40
  106. data/lib/rdoc/markup/to_html_crossref.rb +108 -43
  107. data/lib/rdoc/markup/to_html_snippet.rb +13 -11
  108. data/lib/rdoc/markup/to_joined_paragraph.rb +6 -32
  109. data/lib/rdoc/markup/to_label.rb +11 -12
  110. data/lib/rdoc/markup/to_markdown.rb +13 -14
  111. data/lib/rdoc/markup/to_rdoc.rb +49 -31
  112. data/lib/rdoc/markup/to_table_of_contents.rb +2 -2
  113. data/lib/rdoc/markup/to_test.rb +1 -2
  114. data/lib/rdoc/markup/to_tt_only.rb +3 -4
  115. data/lib/rdoc/markup/verbatim.rb +1 -2
  116. data/lib/rdoc/markup.rb +64 -694
  117. data/lib/rdoc/options.rb +226 -44
  118. data/lib/rdoc/parser/c.rb +231 -246
  119. data/lib/rdoc/parser/changelog.rb +169 -23
  120. data/lib/rdoc/parser/markdown.rb +1 -3
  121. data/lib/rdoc/parser/prism_ruby.rb +1092 -0
  122. data/lib/rdoc/parser/rd.rb +1 -2
  123. data/lib/rdoc/parser/ripper_state_lex.rb +302 -0
  124. data/lib/rdoc/parser/ruby.rb +695 -478
  125. data/lib/rdoc/parser/ruby_tools.rb +33 -36
  126. data/lib/rdoc/parser/simple.rb +4 -4
  127. data/lib/rdoc/parser/text.rb +1 -2
  128. data/lib/rdoc/parser.rb +37 -42
  129. data/lib/rdoc/rd/block_parser.rb +708 -57
  130. data/lib/rdoc/rd/block_parser.ry +15 -11
  131. data/lib/rdoc/rd/inline.rb +5 -6
  132. data/lib/rdoc/rd/inline_parser.rb +787 -140
  133. data/lib/rdoc/rd/inline_parser.ry +1 -1
  134. data/lib/rdoc/rd.rb +4 -5
  135. data/lib/rdoc/rdoc.rb +72 -87
  136. data/lib/rdoc/ri/driver.rb +236 -152
  137. data/lib/rdoc/ri/formatter.rb +1 -1
  138. data/lib/rdoc/ri/paths.rb +4 -18
  139. data/lib/rdoc/ri/store.rb +1 -2
  140. data/lib/rdoc/ri/task.rb +2 -2
  141. data/lib/rdoc/ri.rb +5 -6
  142. data/lib/rdoc/rubygems_hook.rb +98 -20
  143. data/lib/rdoc/servlet.rb +30 -20
  144. data/lib/rdoc/stats/normal.rb +24 -18
  145. data/lib/rdoc/stats/quiet.rb +1 -2
  146. data/lib/rdoc/stats/verbose.rb +1 -3
  147. data/lib/rdoc/stats.rb +6 -7
  148. data/lib/rdoc/store.rb +84 -55
  149. data/lib/rdoc/task.rb +35 -10
  150. data/lib/rdoc/text.rb +40 -27
  151. data/lib/rdoc/token_stream.rb +56 -34
  152. data/lib/rdoc/tom_doc.rb +18 -19
  153. data/lib/rdoc/version.rb +10 -0
  154. data/lib/rdoc.rb +80 -56
  155. data/lib/rubygems_plugin.rb +23 -0
  156. data/man/ri.1 +247 -0
  157. metadata +45 -99
  158. data/.document +0 -5
  159. data/.gitignore +0 -13
  160. data/.travis.yml +0 -24
  161. data/Gemfile +0 -3
  162. data/RI.rdoc +0 -57
  163. data/Rakefile +0 -133
  164. data/bin/console +0 -7
  165. data/bin/setup +0 -6
  166. data/lib/gauntlet_rdoc.rb +0 -82
  167. data/lib/rdoc/generator/template/darkfish/.document +0 -0
  168. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
  169. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
  170. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
  171. data/lib/rdoc/generator/template/json_index/.document +0 -1
  172. data/lib/rdoc/markup/formatter_test_case.rb +0 -764
  173. data/lib/rdoc/markup/inline.rb +0 -2
  174. data/lib/rdoc/markup/special.rb +0 -41
  175. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
  176. data/lib/rdoc/ruby_lex.rb +0 -1367
  177. data/lib/rdoc/ruby_token.rb +0 -461
  178. data/lib/rdoc/test_case.rb +0 -204
  179. data/rdoc.gemspec +0 -57
data/lib/rdoc/options.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  require 'optparse'
3
3
  require 'pathname'
4
4
 
@@ -105,7 +105,9 @@ class RDoc::Options
105
105
  generator_name
106
106
  generator_options
107
107
  generators
108
+ locale
108
109
  op_dir
110
+ page_dir
109
111
  option_parser
110
112
  pipe
111
113
  rdoc_include
@@ -164,7 +166,7 @@ class RDoc::Options
164
166
  ##
165
167
  # Files matching this pattern will be excluded
166
168
 
167
- attr_accessor :exclude
169
+ attr_writer :exclude
168
170
 
169
171
  ##
170
172
  # The list of files to be processed
@@ -231,9 +233,9 @@ class RDoc::Options
231
233
  attr_accessor :main_page
232
234
 
233
235
  ##
234
- # The default markup format. The default is 'rdoc'. 'markdown', 'tomdoc'
235
- # and 'rd' are also built-in.
236
-
236
+ # The markup format.
237
+ # One of: +rdoc+ (the default), +markdown+, +rd+, +tomdoc+.
238
+ # See {Markup Formats}[rdoc-ref:RDoc::Markup@Markup+Formats].
237
239
  attr_accessor :markup
238
240
 
239
241
  ##
@@ -323,6 +325,12 @@ class RDoc::Options
323
325
 
324
326
  attr_accessor :verbosity
325
327
 
328
+ ##
329
+ # Warn if rdoc-ref links can't be resolved
330
+ # Default is +false+
331
+
332
+ attr_accessor :warn_missing_rdoc_ref
333
+
326
334
  ##
327
335
  # URL of web cvs frontend
328
336
 
@@ -338,12 +346,47 @@ class RDoc::Options
338
346
 
339
347
  attr_reader :visibility
340
348
 
341
- def initialize # :nodoc:
349
+ ##
350
+ # Indicates if files of test suites should be skipped
351
+ attr_accessor :skip_tests
352
+
353
+ ##
354
+ # Embed mixin methods, attributes, and constants into class documentation. Set via
355
+ # +--[no-]embed-mixins+ (Default is +false+.)
356
+ attr_accessor :embed_mixins
357
+
358
+ ##
359
+ # Exclude the default patterns as well if true.
360
+ attr_reader :apply_default_exclude
361
+
362
+ ##
363
+ # Words to be ignored in autolink cross-references
364
+ attr_accessor :autolink_excluded_words
365
+
366
+ ##
367
+ # The prefix to use for class and module page paths
368
+
369
+ attr_accessor :class_module_path_prefix
370
+
371
+ ##
372
+ # The prefix to use for file page paths
373
+
374
+ attr_accessor :file_path_prefix
375
+
376
+ def initialize loaded_options = nil # :nodoc:
342
377
  init_ivars
378
+ override loaded_options if loaded_options
343
379
  end
344
380
 
381
+ DEFAULT_EXCLUDE = %w[
382
+ ~\z \.orig\z \.rej\z \.bak\z
383
+ \.gemspec\z
384
+ ]
385
+
345
386
  def init_ivars # :nodoc:
387
+ @autolink_excluded_words = []
346
388
  @dry_run = false
389
+ @embed_mixins = false
347
390
  @exclude = []
348
391
  @files = nil
349
392
  @force_output = false
@@ -377,10 +420,15 @@ class RDoc::Options
377
420
  @update_output_dir = true
378
421
  @verbosity = 1
379
422
  @visibility = :protected
423
+ @warn_missing_rdoc_ref = true
380
424
  @webcvs = nil
381
425
  @write_options = false
382
426
  @encoding = Encoding::UTF_8
383
427
  @charset = @encoding.name
428
+ @skip_tests = true
429
+ @apply_default_exclude = true
430
+ @class_module_path_prefix = nil
431
+ @file_path_prefix = nil
384
432
  end
385
433
 
386
434
  def init_with map # :nodoc:
@@ -390,6 +438,7 @@ class RDoc::Options
390
438
  @encoding = encoding ? Encoding.find(encoding) : encoding
391
439
 
392
440
  @charset = map['charset']
441
+ @embed_mixins = map['embed_mixins']
393
442
  @exclude = map['exclude']
394
443
  @generator_name = map['generator_name']
395
444
  @hyperlink_all = map['hyperlink_all']
@@ -406,6 +455,9 @@ class RDoc::Options
406
455
  @visibility = map['visibility']
407
456
  @webcvs = map['webcvs']
408
457
 
458
+ @apply_default_exclude = map['apply_default_exclude']
459
+ @autolink_excluded_words = map['autolink_excluded_words']
460
+
409
461
  @rdoc_include = sanitize_path map['rdoc_include']
410
462
  @static_path = sanitize_path map['static_path']
411
463
  end
@@ -414,14 +466,52 @@ class RDoc::Options
414
466
  init_with map
415
467
  end
416
468
 
469
+ def override map # :nodoc:
470
+ if map.has_key?('encoding')
471
+ encoding = map['encoding']
472
+ @encoding = encoding ? Encoding.find(encoding) : encoding
473
+ end
474
+
475
+ @charset = map['charset'] if map.has_key?('charset')
476
+ @embed_mixins = map['embed_mixins'] if map.has_key?('embed_mixins')
477
+ @exclude = map['exclude'] if map.has_key?('exclude')
478
+ @generator_name = map['generator_name'] if map.has_key?('generator_name')
479
+ @hyperlink_all = map['hyperlink_all'] if map.has_key?('hyperlink_all')
480
+ @line_numbers = map['line_numbers'] if map.has_key?('line_numbers')
481
+ @locale_name = map['locale_name'] if map.has_key?('locale_name')
482
+ @locale_dir = map['locale_dir'] if map.has_key?('locale_dir')
483
+ @main_page = map['main_page'] if map.has_key?('main_page')
484
+ @markup = map['markup'] if map.has_key?('markup')
485
+ @op_dir = map['op_dir'] if map.has_key?('op_dir')
486
+ @page_dir = map['page_dir'] if map.has_key?('page_dir')
487
+ @show_hash = map['show_hash'] if map.has_key?('show_hash')
488
+ @tab_width = map['tab_width'] if map.has_key?('tab_width')
489
+ @template_dir = map['template_dir'] if map.has_key?('template_dir')
490
+ @title = map['title'] if map.has_key?('title')
491
+ @visibility = map['visibility'] if map.has_key?('visibility')
492
+ @webcvs = map['webcvs'] if map.has_key?('webcvs')
493
+ @autolink_excluded_words = map['autolink_excluded_words'] if map.has_key?('autolink_excluded_words')
494
+ @apply_default_exclude = map['apply_default_exclude'] if map.has_key?('apply_default_exclude')
495
+
496
+ @warn_missing_rdoc_ref = map['warn_missing_rdoc_ref'] if map.has_key?('warn_missing_rdoc_ref')
497
+
498
+ if map.has_key?('rdoc_include')
499
+ @rdoc_include = sanitize_path map['rdoc_include']
500
+ end
501
+ if map.has_key?('static_path')
502
+ @static_path = sanitize_path map['static_path']
503
+ end
504
+ end
505
+
417
506
  def == other # :nodoc:
418
507
  self.class === other and
419
508
  @encoding == other.encoding and
509
+ @embed_mixins == other.embed_mixins and
420
510
  @generator_name == other.generator_name and
421
511
  @hyperlink_all == other.hyperlink_all and
422
512
  @line_numbers == other.line_numbers and
423
513
  @locale == other.locale and
424
- @locale_dir == other.locale_dir and
514
+ @locale_dir == other.locale_dir and
425
515
  @main_page == other.main_page and
426
516
  @markup == other.markup and
427
517
  @op_dir == other.op_dir and
@@ -432,7 +522,9 @@ class RDoc::Options
432
522
  @template == other.template and
433
523
  @title == other.title and
434
524
  @visibility == other.visibility and
435
- @webcvs == other.webcvs
525
+ @webcvs == other.webcvs and
526
+ @apply_default_exclude == other.apply_default_exclude and
527
+ @autolink_excluded_words == other.autolink_excluded_words
436
528
  end
437
529
 
438
530
  ##
@@ -478,18 +570,37 @@ class RDoc::Options
478
570
  ##
479
571
  # For dumping YAML
480
572
 
481
- def encode_with coder # :nodoc:
573
+ def to_yaml(*options) # :nodoc:
482
574
  encoding = @encoding ? @encoding.name : nil
483
575
 
484
- coder.add 'encoding', encoding
485
- coder.add 'static_path', sanitize_path(@static_path)
486
- coder.add 'rdoc_include', sanitize_path(@rdoc_include)
576
+ yaml = {}
577
+ yaml['encoding'] = encoding
578
+ yaml['static_path'] = sanitize_path(@static_path)
579
+ yaml['rdoc_include'] = sanitize_path(@rdoc_include)
580
+ yaml['page_dir'] = (sanitize_path([@page_dir]).first if @page_dir)
487
581
 
488
582
  ivars = instance_variables.map { |ivar| ivar.to_s[1..-1] }
489
583
  ivars -= SPECIAL
490
584
 
491
585
  ivars.sort.each do |ivar|
492
- coder.add ivar, instance_variable_get("@#{ivar}")
586
+ yaml[ivar] = instance_variable_get("@#{ivar}")
587
+ end
588
+ yaml.to_yaml
589
+ end
590
+
591
+ ##
592
+ # Create a regexp for #exclude
593
+
594
+ def exclude
595
+ if @exclude.nil? or Regexp === @exclude then
596
+ # done, #finish is being re-run
597
+ @exclude
598
+ elsif !@apply_default_exclude and @exclude.empty? then
599
+ nil
600
+ else
601
+ exclude = @exclude
602
+ exclude |= DEFAULT_EXCLUDE if @apply_default_exclude
603
+ Regexp.new(exclude.join("|"))
493
604
  end
494
605
  end
495
606
 
@@ -499,20 +610,20 @@ class RDoc::Options
499
610
  # #template.
500
611
 
501
612
  def finish
613
+ if @write_options then
614
+ write_options
615
+ exit
616
+ end
617
+
502
618
  @op_dir ||= 'doc'
503
619
 
504
- @rdoc_include << "." if @rdoc_include.empty?
505
620
  root = @root.to_s
506
- @rdoc_include << root unless @rdoc_include.include?(root)
507
-
508
- if @exclude.nil? or Regexp === @exclude then
509
- # done, #finish is being re-run
510
- elsif @exclude.empty? then
511
- @exclude = nil
512
- else
513
- @exclude = Regexp.new(@exclude.join("|"))
621
+ if @rdoc_include.empty? || !@rdoc_include.include?(root)
622
+ @rdoc_include << root
514
623
  end
515
624
 
625
+ @exclude = self.exclude
626
+
516
627
  finish_page_dir
517
628
 
518
629
  check_files
@@ -542,9 +653,15 @@ class RDoc::Options
542
653
  def finish_page_dir
543
654
  return unless @page_dir
544
655
 
545
- @files << @page_dir.to_s
656
+ @files << @page_dir
546
657
 
547
- page_dir = @page_dir.expand_path.relative_path_from @root
658
+ page_dir = Pathname(@page_dir)
659
+ begin
660
+ page_dir = page_dir.expand_path.relative_path_from @root
661
+ rescue ArgumentError
662
+ # On Windows, sometimes crosses different drive letters.
663
+ page_dir = page_dir.expand_path
664
+ end
548
665
 
549
666
  @page_dir = page_dir
550
667
  end
@@ -617,23 +734,23 @@ Usage: #{opt.program_name} [options] [names...]
617
734
 
618
735
  EOF
619
736
 
620
- parsers = Hash.new { |h,parser| h[parser] = [] }
737
+ parsers = Hash.new { |h, parser| h[parser] = [] }
621
738
 
622
739
  RDoc::Parser.parsers.each do |regexp, parser|
623
740
  parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source
624
741
  end
625
742
 
626
743
  parsers.sort.each do |parser, regexp|
627
- opt.banner << " - #{parser}: #{regexp.join ', '}\n"
744
+ opt.banner += " - #{parser}: #{regexp.join ', '}\n"
628
745
  end
629
- opt.banner << " - TomDoc: Only in ruby files\n"
746
+ opt.banner += " - TomDoc: Only in ruby files\n"
630
747
 
631
- opt.banner << "\n The following options are deprecated:\n\n"
748
+ opt.banner += "\n The following options are deprecated:\n\n"
632
749
 
633
750
  name_length = DEPRECATED.keys.sort_by { |k| k.length }.last.length
634
751
 
635
752
  DEPRECATED.sort_by { |k,| k }.each do |name, reason|
636
- opt.banner << " %*1$2$s %3$s\n" % [-name_length, name, reason]
753
+ opt.banner += " %*1$2$s %3$s\n" % [-name_length, name, reason]
637
754
  end
638
755
 
639
756
  opt.accept Template do |template|
@@ -717,6 +834,18 @@ Usage: #{opt.program_name} [options] [names...]
717
834
  @exclude << value
718
835
  end
719
836
 
837
+ opt.on("--[no-]apply-default-exclude",
838
+ "Use default PATTERN to exclude.") do |value|
839
+ @apply_default_exclude = value
840
+ end
841
+
842
+ opt.separator nil
843
+
844
+ opt.on("--no-skipping-tests", nil,
845
+ "Don't skip generating documentation for test and spec files") do |value|
846
+ @skip_tests = false
847
+ end
848
+
720
849
  opt.separator nil
721
850
 
722
851
  opt.on("--extension=NEW=OLD", "-E",
@@ -738,7 +867,7 @@ Usage: #{opt.program_name} [options] [names...]
738
867
 
739
868
  opt.on("--[no-]force-update", "-U",
740
869
  "Forces rdoc to scan all sources even if",
741
- "newer than the flag file.") do |value|
870
+ "no files are newer than the flag file.") do |value|
742
871
  @force_update = value
743
872
  end
744
873
 
@@ -769,6 +898,14 @@ Usage: #{opt.program_name} [options] [names...]
769
898
 
770
899
  opt.separator nil
771
900
 
901
+ opt.on("--[no-]embed-mixins",
902
+ "Embed mixin methods, attributes, and constants",
903
+ "into class documentation. (default false)") do |value|
904
+ @embed_mixins = value
905
+ end
906
+
907
+ opt.separator nil
908
+
772
909
  markup_formats = RDoc::Text::MARKUP_FORMAT.keys.sort
773
910
 
774
911
  opt.on("--markup=MARKUP", markup_formats,
@@ -798,7 +935,7 @@ Usage: #{opt.program_name} [options] [names...]
798
935
  "such files at your project root.",
799
936
  "NOTE: Do not use the same file name in",
800
937
  "the page dir and the root of your project") do |page_dir|
801
- @page_dir = Pathname(page_dir)
938
+ @page_dir = page_dir
802
939
  end
803
940
 
804
941
  opt.separator nil
@@ -873,6 +1010,13 @@ Usage: #{opt.program_name} [options] [names...]
873
1010
 
874
1011
  opt.separator nil
875
1012
 
1013
+ opt.on("--autolink-excluded-words=WORDS", Array,
1014
+ "Words to be ignored in autolink cross-references") do |value|
1015
+ @autolink_excluded_words.concat value
1016
+ end
1017
+
1018
+ opt.separator nil
1019
+
876
1020
  opt.on("--hyperlink-all", "-A",
877
1021
  "Generate hyperlinks for all words that",
878
1022
  "correspond to known methods, even if they",
@@ -922,7 +1066,7 @@ Usage: #{opt.program_name} [options] [names...]
922
1066
  opt.on("--template-stylesheets=FILES", PathArray,
923
1067
  "Set (or add to) the list of files to",
924
1068
  "include with the html template.") do |value|
925
- @template_stylesheets << value
1069
+ @template_stylesheets.concat value
926
1070
  end
927
1071
 
928
1072
  opt.separator nil
@@ -1014,6 +1158,13 @@ Usage: #{opt.program_name} [options] [names...]
1014
1158
 
1015
1159
  opt.separator nil
1016
1160
 
1161
+ opt.on("--warn-missing-rdoc-ref",
1162
+ "Warn if rdoc-ref links can't be resolved") do |value|
1163
+ @warn_missing_rdoc_ref = value
1164
+ end
1165
+
1166
+ opt.separator nil
1167
+
1017
1168
  opt.on("--[no-]ignore-invalid",
1018
1169
  "Ignore invalid options and continue",
1019
1170
  "(default true).") do |value|
@@ -1087,7 +1238,7 @@ Usage: #{opt.program_name} [options] [names...]
1087
1238
 
1088
1239
  unless quiet then
1089
1240
  deprecated.each do |opt|
1090
- $stderr.puts 'option ' << opt << ' is deprecated: ' << DEPRECATED[opt]
1241
+ $stderr.puts 'option ' + opt + ' is deprecated: ' + DEPRECATED[opt]
1091
1242
  end
1092
1243
  end
1093
1244
 
@@ -1110,13 +1261,6 @@ Usage: #{opt.program_name} [options] [names...]
1110
1261
 
1111
1262
  @files = argv.dup
1112
1263
 
1113
- finish
1114
-
1115
- if @write_options then
1116
- write_options
1117
- exit
1118
- end
1119
-
1120
1264
  self
1121
1265
  end
1122
1266
 
@@ -1143,8 +1287,17 @@ Usage: #{opt.program_name} [options] [names...]
1143
1287
 
1144
1288
  path.reject do |item|
1145
1289
  path = Pathname.new(item).expand_path
1146
- relative = path.relative_path_from(dot).to_s
1147
- relative.start_with? '..'
1290
+ is_reject = nil
1291
+ relative = nil
1292
+ begin
1293
+ relative = path.relative_path_from(dot).to_s
1294
+ rescue ArgumentError
1295
+ # On Windows, sometimes crosses different drive letters.
1296
+ is_reject = true
1297
+ else
1298
+ is_reject = relative.start_with? '..'
1299
+ end
1300
+ is_reject
1148
1301
  end
1149
1302
  end
1150
1303
 
@@ -1217,11 +1370,40 @@ Usage: #{opt.program_name} [options] [names...]
1217
1370
  def write_options
1218
1371
  RDoc.load_yaml
1219
1372
 
1220
- open '.rdoc_options', 'w' do |io|
1373
+ File.open '.rdoc_options', 'w' do |io|
1221
1374
  io.set_encoding Encoding::UTF_8
1222
1375
 
1223
- YAML.dump self, io
1376
+ io.print to_yaml
1224
1377
  end
1225
1378
  end
1226
1379
 
1380
+ ##
1381
+ # Loads options from .rdoc_options if the file exists, otherwise creates a
1382
+ # new RDoc::Options instance.
1383
+
1384
+ def self.load_options
1385
+ options_file = File.expand_path '.rdoc_options'
1386
+ return RDoc::Options.new unless File.exist? options_file
1387
+
1388
+ RDoc.load_yaml
1389
+
1390
+ begin
1391
+ options = YAML.safe_load File.read('.rdoc_options'), permitted_classes: [RDoc::Options, Symbol]
1392
+ rescue Psych::SyntaxError
1393
+ raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
1394
+ end
1395
+
1396
+ return RDoc::Options.new unless options # Allow empty file.
1397
+
1398
+ raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
1399
+ RDoc::Options === options or Hash === options
1400
+
1401
+ if Hash === options
1402
+ # Override the default values with the contents of YAML file.
1403
+ options = RDoc::Options.new options
1404
+ end
1405
+
1406
+ options
1407
+ end
1408
+
1227
1409
  end