rdoc 6.3.4.1 → 8.0.0

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 (205) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +195 -0
  3. data/History.rdoc +65 -63
  4. data/LEGAL.rdoc +7 -1
  5. data/LICENSE.rdoc +6 -0
  6. data/README.md +236 -0
  7. data/RI.md +842 -0
  8. data/TODO.rdoc +8 -7
  9. data/doc/markup_reference/markdown.md +659 -0
  10. data/doc/markup_reference/rdoc.rdoc +1169 -0
  11. data/exe/rdoc +0 -1
  12. data/lib/rdoc/{alias.rb → code_object/alias.rb} +4 -18
  13. data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +50 -24
  14. data/lib/rdoc/{attr.rb → code_object/attr.rb} +16 -14
  15. data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +225 -58
  16. data/lib/rdoc/{constant.rb → code_object/constant.rb} +44 -10
  17. data/lib/rdoc/code_object/context/section.rb +182 -0
  18. data/lib/rdoc/{context.rb → code_object/context.rb} +78 -106
  19. data/lib/rdoc/{extend.rb → code_object/extend.rb} +0 -1
  20. data/lib/rdoc/{include.rb → code_object/include.rb} +0 -1
  21. data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +46 -48
  22. data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +6 -4
  23. data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +2 -3
  24. data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +2 -3
  25. data/lib/rdoc/{require.rb → code_object/require.rb} +1 -2
  26. data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +5 -1
  27. data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +60 -63
  28. data/lib/rdoc/code_object.rb +11 -39
  29. data/lib/rdoc/code_objects.rb +1 -2
  30. data/lib/rdoc/comment.rb +202 -99
  31. data/lib/rdoc/cross_reference.rb +75 -62
  32. data/lib/rdoc/encoding.rb +8 -24
  33. data/lib/rdoc/erb_partial.rb +1 -2
  34. data/lib/rdoc/erbio.rb +3 -8
  35. data/lib/rdoc/generator/aliki.rb +200 -0
  36. data/lib/rdoc/generator/darkfish.rb +156 -122
  37. data/lib/rdoc/generator/json_index.rb +8 -24
  38. data/lib/rdoc/generator/markup.rb +70 -34
  39. data/lib/rdoc/generator/pot/message_extractor.rb +7 -7
  40. data/lib/rdoc/generator/pot/po.rb +1 -1
  41. data/lib/rdoc/generator/pot/po_entry.rb +8 -8
  42. data/lib/rdoc/generator/pot.rb +1 -5
  43. data/lib/rdoc/generator/ri.rb +1 -2
  44. data/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
  45. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  46. data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  47. data/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
  48. data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  49. data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  50. data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  51. data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  52. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
  53. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
  54. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  55. data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  56. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  57. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  58. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  59. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  60. data/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
  61. data/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
  62. data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  63. data/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
  64. data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
  65. data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  66. data/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
  67. data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  68. data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  69. data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  70. data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  71. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  72. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  73. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
  74. data/lib/rdoc/generator/template/darkfish/_head.rhtml +35 -14
  75. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -5
  76. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +11 -9
  77. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +11 -9
  78. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
  79. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +20 -11
  80. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +25 -5
  81. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -9
  82. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +2 -1
  83. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  84. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +28 -7
  85. data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  86. data/lib/rdoc/generator/template/darkfish/class.rhtml +138 -90
  87. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +420 -358
  88. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  89. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  90. data/lib/rdoc/generator/template/darkfish/index.rhtml +14 -12
  91. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +59 -3
  92. data/lib/rdoc/generator/template/darkfish/js/search.js +15 -5
  93. data/lib/rdoc/generator/template/darkfish/page.rhtml +7 -6
  94. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +12 -9
  95. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +24 -21
  96. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +35 -21
  97. data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
  98. data/lib/rdoc/generator/template/json_index/js/searcher.js +48 -6
  99. data/lib/rdoc/generator.rb +6 -5
  100. data/lib/rdoc/i18n/text.rb +3 -3
  101. data/lib/rdoc/i18n.rb +1 -1
  102. data/lib/rdoc/known_classes.rb +5 -4
  103. data/lib/rdoc/markdown/entities.rb +0 -1
  104. data/lib/rdoc/markdown/literals.kpeg +0 -2
  105. data/lib/rdoc/markdown/literals.rb +0 -1
  106. data/lib/rdoc/markdown.kpeg +140 -62
  107. data/lib/rdoc/markdown.rb +1015 -873
  108. data/lib/rdoc/markup/blank_line.rb +25 -24
  109. data/lib/rdoc/markup/block_quote.rb +1 -2
  110. data/lib/rdoc/markup/document.rb +10 -11
  111. data/lib/rdoc/markup/element.rb +21 -0
  112. data/lib/rdoc/markup/formatter.rb +134 -115
  113. data/lib/rdoc/markup/hard_break.rb +30 -28
  114. data/lib/rdoc/markup/heading.rb +163 -72
  115. data/lib/rdoc/markup/include.rb +3 -4
  116. data/lib/rdoc/markup/indented_paragraph.rb +4 -5
  117. data/lib/rdoc/markup/inline_parser.rb +312 -0
  118. data/lib/rdoc/markup/list.rb +6 -7
  119. data/lib/rdoc/markup/list_item.rb +6 -7
  120. data/lib/rdoc/markup/paragraph.rb +2 -3
  121. data/lib/rdoc/markup/parser.rb +29 -19
  122. data/lib/rdoc/markup/pre_process.rb +39 -18
  123. data/lib/rdoc/markup/raw.rb +52 -56
  124. data/lib/rdoc/markup/rule.rb +2 -3
  125. data/lib/rdoc/markup/table.rb +49 -32
  126. data/lib/rdoc/markup/to_ansi.rb +58 -8
  127. data/lib/rdoc/markup/to_bs.rb +47 -38
  128. data/lib/rdoc/markup/to_html.rb +343 -105
  129. data/lib/rdoc/markup/to_html_crossref.rb +143 -58
  130. data/lib/rdoc/markup/to_html_snippet.rb +78 -76
  131. data/lib/rdoc/markup/to_joined_paragraph.rb +3 -9
  132. data/lib/rdoc/markup/to_label.rb +34 -25
  133. data/lib/rdoc/markup/to_markdown.rb +74 -51
  134. data/lib/rdoc/markup/to_rdoc.rb +141 -82
  135. data/lib/rdoc/markup/to_table_of_contents.rb +4 -5
  136. data/lib/rdoc/markup/to_test.rb +10 -3
  137. data/lib/rdoc/markup/to_tt_only.rb +17 -31
  138. data/lib/rdoc/markup/verbatim.rb +5 -6
  139. data/lib/rdoc/markup.rb +59 -707
  140. data/lib/rdoc/options.rb +228 -101
  141. data/lib/rdoc/parser/c.rb +186 -184
  142. data/lib/rdoc/parser/changelog.rb +57 -13
  143. data/lib/rdoc/parser/markdown.rb +0 -2
  144. data/lib/rdoc/parser/rbs.rb +275 -0
  145. data/lib/rdoc/parser/rd.rb +0 -1
  146. data/lib/rdoc/parser/ruby.rb +963 -2024
  147. data/lib/rdoc/parser/ruby_colorizer.rb +253 -0
  148. data/lib/rdoc/parser/simple.rb +6 -23
  149. data/lib/rdoc/parser/text.rb +0 -1
  150. data/lib/rdoc/parser.rb +35 -14
  151. data/lib/rdoc/rbs_helper.rb +186 -0
  152. data/lib/rdoc/rd/block_parser.rb +659 -11
  153. data/lib/rdoc/rd/block_parser.ry +13 -9
  154. data/lib/rdoc/rd/inline.rb +4 -5
  155. data/lib/rdoc/rd/inline_parser.rb +646 -2
  156. data/lib/rdoc/rd.rb +4 -5
  157. data/lib/rdoc/rdoc.rb +234 -90
  158. data/lib/rdoc/ri/driver.rb +172 -172
  159. data/lib/rdoc/ri/paths.rb +3 -3
  160. data/lib/rdoc/{servlet.rb → ri/servlet.rb} +28 -27
  161. data/lib/rdoc/ri/store.rb +0 -1
  162. data/lib/rdoc/ri/task.rb +3 -3
  163. data/lib/rdoc/ri.rb +5 -5
  164. data/lib/rdoc/rubygems_hook.rb +106 -25
  165. data/lib/rdoc/server.rb +460 -0
  166. data/lib/rdoc/stats/normal.rb +1 -1
  167. data/lib/rdoc/stats/quiet.rb +1 -2
  168. data/lib/rdoc/stats/verbose.rb +3 -5
  169. data/lib/rdoc/stats.rb +158 -136
  170. data/lib/rdoc/store.rb +267 -48
  171. data/lib/rdoc/task.rb +54 -28
  172. data/lib/rdoc/text.rb +60 -120
  173. data/lib/rdoc/token_stream.rb +30 -45
  174. data/lib/rdoc/tom_doc.rb +9 -15
  175. data/lib/rdoc/version.rb +3 -1
  176. data/lib/rdoc.rb +90 -52
  177. data/lib/rubygems_plugin.rb +14 -0
  178. data/man/ri.1 +2 -0
  179. data/rdoc-logo.svg +43 -0
  180. data/rdoc.gemspec +25 -200
  181. metadata +120 -53
  182. data/CONTRIBUTING.rdoc +0 -220
  183. data/ExampleMarkdown.md +0 -37
  184. data/ExampleRDoc.rdoc +0 -208
  185. data/Gemfile +0 -12
  186. data/README.rdoc +0 -129
  187. data/RI.rdoc +0 -57
  188. data/Rakefile +0 -101
  189. data/bin/console +0 -7
  190. data/bin/setup +0 -6
  191. data/lib/rdoc/anon_class.rb +0 -11
  192. data/lib/rdoc/context/section.rb +0 -232
  193. data/lib/rdoc/generator/template/darkfish/.document +0 -0
  194. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
  195. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
  196. data/lib/rdoc/generator/template/json_index/.document +0 -1
  197. data/lib/rdoc/ghost_method.rb +0 -7
  198. data/lib/rdoc/markup/attr_changer.rb +0 -23
  199. data/lib/rdoc/markup/attr_span.rb +0 -36
  200. data/lib/rdoc/markup/attribute_manager.rb +0 -409
  201. data/lib/rdoc/markup/attributes.rb +0 -71
  202. data/lib/rdoc/markup/regexp_handling.rb +0 -41
  203. data/lib/rdoc/meta_method.rb +0 -7
  204. data/lib/rdoc/parser/ripper_state_lex.rb +0 -590
  205. data/lib/rdoc/parser/ruby_tools.rb +0 -167
data/lib/rdoc/options.rb CHANGED
@@ -74,23 +74,6 @@ require 'pathname'
74
74
 
75
75
  class RDoc::Options
76
76
 
77
- ##
78
- # The deprecated options.
79
-
80
- DEPRECATED = {
81
- '--accessor' => 'support discontinued',
82
- '--diagram' => 'support discontinued',
83
- '--help-output' => 'support discontinued',
84
- '--image-format' => 'was an option for --diagram',
85
- '--inline-source' => 'source code is now always inlined',
86
- '--merge' => 'ri now always merges class information',
87
- '--one-file' => 'support discontinued',
88
- '--op-name' => 'support discontinued',
89
- '--opname' => 'support discontinued',
90
- '--promiscuous' => 'files always only document their content',
91
- '--ri-system' => 'Ruby installers use other techniques',
92
- }
93
-
94
77
  ##
95
78
  # RDoc options ignored (or handled specially) by --write-options
96
79
 
@@ -105,13 +88,15 @@ class RDoc::Options
105
88
  generator_name
106
89
  generator_options
107
90
  generators
91
+ locale
108
92
  op_dir
93
+ page_dir
109
94
  option_parser
110
95
  pipe
111
96
  rdoc_include
112
97
  root
98
+ server_port
113
99
  static_path
114
- stylesheet_url
115
100
  template
116
101
  template_dir
117
102
  update_output_dir
@@ -231,9 +216,9 @@ class RDoc::Options
231
216
  attr_accessor :main_page
232
217
 
233
218
  ##
234
- # The default markup format. The default is 'rdoc'. 'markdown', 'tomdoc'
235
- # and 'rd' are also built-in.
236
-
219
+ # The markup format.
220
+ # One of: +rdoc+ (the default), +markdown+, +rd+, +tomdoc+.
221
+ # See {Markup Formats}[rdoc-ref:RDoc::Markup@Markup+Formats].
237
222
  attr_accessor :markup
238
223
 
239
224
  ##
@@ -323,6 +308,12 @@ class RDoc::Options
323
308
 
324
309
  attr_accessor :verbosity
325
310
 
311
+ ##
312
+ # Warn if rdoc-ref links can't be resolved
313
+ # Default is +true+
314
+
315
+ attr_accessor :warn_missing_rdoc_ref
316
+
326
317
  ##
327
318
  # URL of web cvs frontend
328
319
 
@@ -338,24 +329,81 @@ class RDoc::Options
338
329
 
339
330
  attr_reader :visibility
340
331
 
341
- def initialize loaded_options = nil # :nodoc:
332
+ ##
333
+ # When set to a port number, starts a live-reloading server instead of
334
+ # writing files. Defaults to +false+ (no server). Set via
335
+ # <tt>--server[=PORT]</tt>.
336
+
337
+ attr_reader :server_port
338
+
339
+ ##
340
+ # Indicates if files of test suites should be skipped
341
+ attr_accessor :skip_tests
342
+
343
+ ##
344
+ # Embed mixin methods, attributes, and constants into class documentation. Set via
345
+ # +--[no-]embed-mixins+ (Default is +false+.)
346
+ attr_accessor :embed_mixins
347
+
348
+ ##
349
+ # Exclude the default patterns as well if true.
350
+ attr_reader :apply_default_exclude
351
+
352
+ ##
353
+ # Words to be ignored in autolink cross-references
354
+ attr_accessor :autolink_excluded_words
355
+
356
+ ##
357
+ # The prefix to use for class and module page paths
358
+
359
+ attr_accessor :class_module_path_prefix
360
+
361
+ ##
362
+ # The prefix to use for file page paths
363
+
364
+ attr_accessor :file_path_prefix
365
+
366
+ ##
367
+ # The preferred root URL for the documentation
368
+
369
+ attr_accessor :canonical_root
370
+
371
+ ##
372
+ # Custom footer content configuration for themes that support it.
373
+ # Currently only supported by the Aliki theme.
374
+ #
375
+ # A hash where keys are column titles and values are hashes of link text => URL pairs.
376
+ # Each column will be displayed in the upper footer section.
377
+ #
378
+ # Example:
379
+ # {
380
+ # "DOCUMENTATION" => {"Home" => "/index.html", "Guide" => "/guide.html"},
381
+ # "RESOURCES" => {"RDoc" => "https://ruby.github.io/rdoc/", "GitHub" => "https://github.com/ruby/rdoc"}
382
+ # }
383
+
384
+ attr_accessor :footer_content
385
+
386
+ def initialize(loaded_options = nil) # :nodoc:
342
387
  init_ivars
343
388
  override loaded_options if loaded_options
344
389
  end
345
390
 
391
+ DEFAULT_EXCLUDE = %w[
392
+ ~\z \.orig\z \.rej\z \.bak\z
393
+ \.gemspec\z
394
+ ]
395
+
346
396
  def init_ivars # :nodoc:
397
+ @autolink_excluded_words = []
347
398
  @dry_run = false
348
- @exclude = %w[
349
- ~\z \.orig\z \.rej\z \.bak\z
350
- \.gemspec\z
351
- ]
399
+ @embed_mixins = false
400
+ @exclude = []
352
401
  @files = nil
353
402
  @force_output = false
354
403
  @force_update = true
355
- @generator = nil
356
- @generator_name = nil
357
- @generator_options = []
404
+ @generator_name = "aliki"
358
405
  @generators = RDoc::RDoc::GENERATORS
406
+ @generator_options = []
359
407
  @hyperlink_all = false
360
408
  @line_numbers = false
361
409
  @locale = nil
@@ -370,9 +418,9 @@ class RDoc::Options
370
418
  @output_decoration = true
371
419
  @rdoc_include = []
372
420
  @root = Pathname(Dir.pwd)
421
+ @server_port = false
373
422
  @show_hash = false
374
423
  @static_path = []
375
- @stylesheet_url = nil # TODO remove in RDoc 4
376
424
  @tab_width = 8
377
425
  @template = nil
378
426
  @template_dir = nil
@@ -381,19 +429,27 @@ class RDoc::Options
381
429
  @update_output_dir = true
382
430
  @verbosity = 1
383
431
  @visibility = :protected
432
+ @warn_missing_rdoc_ref = true
384
433
  @webcvs = nil
385
434
  @write_options = false
386
435
  @encoding = Encoding::UTF_8
387
436
  @charset = @encoding.name
437
+ @skip_tests = true
438
+ @apply_default_exclude = true
439
+ @class_module_path_prefix = nil
440
+ @file_path_prefix = nil
441
+ @canonical_root = nil
442
+ @footer_content = nil
388
443
  end
389
444
 
390
- def init_with map # :nodoc:
445
+ def init_with(map) # :nodoc:
391
446
  init_ivars
392
447
 
393
448
  encoding = map['encoding']
394
449
  @encoding = encoding ? Encoding.find(encoding) : encoding
395
450
 
396
451
  @charset = map['charset']
452
+ @embed_mixins = map['embed_mixins']
397
453
  @exclude = map['exclude']
398
454
  @generator_name = map['generator_name']
399
455
  @hyperlink_all = map['hyperlink_all']
@@ -410,21 +466,26 @@ class RDoc::Options
410
466
  @visibility = map['visibility']
411
467
  @webcvs = map['webcvs']
412
468
 
469
+ @apply_default_exclude = map['apply_default_exclude']
470
+ @autolink_excluded_words = map['autolink_excluded_words']
471
+ @footer_content = map['footer_content']
472
+
413
473
  @rdoc_include = sanitize_path map['rdoc_include']
414
474
  @static_path = sanitize_path map['static_path']
415
475
  end
416
476
 
417
- def yaml_initialize tag, map # :nodoc:
477
+ def yaml_initialize(tag, map) # :nodoc:
418
478
  init_with map
419
479
  end
420
480
 
421
- def override map # :nodoc:
481
+ def override(map) # :nodoc:
422
482
  if map.has_key?('encoding')
423
483
  encoding = map['encoding']
424
484
  @encoding = encoding ? Encoding.find(encoding) : encoding
425
485
  end
426
486
 
427
487
  @charset = map['charset'] if map.has_key?('charset')
488
+ @embed_mixins = map['embed_mixins'] if map.has_key?('embed_mixins')
428
489
  @exclude = map['exclude'] if map.has_key?('exclude')
429
490
  @generator_name = map['generator_name'] if map.has_key?('generator_name')
430
491
  @hyperlink_all = map['hyperlink_all'] if map.has_key?('hyperlink_all')
@@ -434,12 +495,19 @@ class RDoc::Options
434
495
  @main_page = map['main_page'] if map.has_key?('main_page')
435
496
  @markup = map['markup'] if map.has_key?('markup')
436
497
  @op_dir = map['op_dir'] if map.has_key?('op_dir')
498
+ @page_dir = map['page_dir'] if map.has_key?('page_dir')
437
499
  @show_hash = map['show_hash'] if map.has_key?('show_hash')
438
500
  @tab_width = map['tab_width'] if map.has_key?('tab_width')
439
501
  @template_dir = map['template_dir'] if map.has_key?('template_dir')
440
502
  @title = map['title'] if map.has_key?('title')
441
503
  @visibility = map['visibility'] if map.has_key?('visibility')
442
504
  @webcvs = map['webcvs'] if map.has_key?('webcvs')
505
+ @autolink_excluded_words = map['autolink_excluded_words'] if map.has_key?('autolink_excluded_words')
506
+ @apply_default_exclude = map['apply_default_exclude'] if map.has_key?('apply_default_exclude')
507
+ @canonical_root = map['canonical_root'] if map.has_key?('canonical_root')
508
+ @footer_content = map['footer_content'] if map.has_key?('footer_content')
509
+
510
+ @warn_missing_rdoc_ref = map['warn_missing_rdoc_ref'] if map.has_key?('warn_missing_rdoc_ref')
443
511
 
444
512
  if map.has_key?('rdoc_include')
445
513
  @rdoc_include = sanitize_path map['rdoc_include']
@@ -449,14 +517,15 @@ class RDoc::Options
449
517
  end
450
518
  end
451
519
 
452
- def == other # :nodoc:
520
+ def ==(other) # :nodoc:
453
521
  self.class === other and
454
522
  @encoding == other.encoding and
523
+ @embed_mixins == other.embed_mixins and
455
524
  @generator_name == other.generator_name and
456
525
  @hyperlink_all == other.hyperlink_all and
457
526
  @line_numbers == other.line_numbers and
458
527
  @locale == other.locale and
459
- @locale_dir == other.locale_dir and
528
+ @locale_dir == other.locale_dir and
460
529
  @main_page == other.main_page and
461
530
  @markup == other.markup and
462
531
  @op_dir == other.op_dir and
@@ -467,7 +536,9 @@ class RDoc::Options
467
536
  @template == other.template and
468
537
  @title == other.title and
469
538
  @visibility == other.visibility and
470
- @webcvs == other.webcvs
539
+ @webcvs == other.webcvs and
540
+ @apply_default_exclude == other.apply_default_exclude and
541
+ @autolink_excluded_words == other.autolink_excluded_words
471
542
  end
472
543
 
473
544
  ##
@@ -513,18 +584,26 @@ class RDoc::Options
513
584
  ##
514
585
  # For dumping YAML
515
586
 
516
- def encode_with coder # :nodoc:
587
+ def to_yaml(*options) # :nodoc:
517
588
  encoding = @encoding ? @encoding.name : nil
518
589
 
519
- coder.add 'encoding', encoding
520
- coder.add 'static_path', sanitize_path(@static_path)
521
- coder.add 'rdoc_include', sanitize_path(@rdoc_include)
590
+ yaml = {}
591
+ yaml['encoding'] = encoding
592
+ yaml['static_path'] = sanitize_path(@static_path)
593
+ yaml['rdoc_include'] = sanitize_path(@rdoc_include)
594
+ yaml['page_dir'] = (sanitize_path([@page_dir]).first if @page_dir)
522
595
 
523
596
  ivars = instance_variables.map { |ivar| ivar.to_s[1..-1] }
524
597
  ivars -= SPECIAL
525
598
 
526
599
  ivars.sort.each do |ivar|
527
- coder.add ivar, instance_variable_get("@#{ivar}")
600
+ yaml[ivar] = instance_variable_get("@#{ivar}")
601
+ end
602
+
603
+ if yaml.respond_to?(:to_yaml)
604
+ yaml.to_yaml
605
+ else
606
+ RDoc.yaml_serializer.dump(yaml)
528
607
  end
529
608
  end
530
609
 
@@ -535,10 +614,12 @@ class RDoc::Options
535
614
  if @exclude.nil? or Regexp === @exclude then
536
615
  # done, #finish is being re-run
537
616
  @exclude
538
- elsif @exclude.empty? then
617
+ elsif !@apply_default_exclude and @exclude.empty? then
539
618
  nil
540
619
  else
541
- Regexp.new(@exclude.join("|"))
620
+ exclude = @exclude
621
+ exclude |= DEFAULT_EXCLUDE if @apply_default_exclude
622
+ Regexp.new(exclude.join("|"))
542
623
  end
543
624
  end
544
625
 
@@ -548,11 +629,17 @@ class RDoc::Options
548
629
  # #template.
549
630
 
550
631
  def finish
632
+ if @write_options then
633
+ write_options
634
+ exit
635
+ end
636
+
551
637
  @op_dir ||= 'doc'
552
638
 
553
- @rdoc_include << "." if @rdoc_include.empty?
554
639
  root = @root.to_s
555
- @rdoc_include << root unless @rdoc_include.include?(root)
640
+ if @rdoc_include.empty? || !@rdoc_include.include?(root)
641
+ @rdoc_include << root
642
+ end
556
643
 
557
644
  @exclude = self.exclude
558
645
 
@@ -585,14 +672,14 @@ class RDoc::Options
585
672
  def finish_page_dir
586
673
  return unless @page_dir
587
674
 
588
- @files << @page_dir.to_s
675
+ @files << @page_dir
589
676
 
590
- page_dir = nil
677
+ page_dir = Pathname(@page_dir)
591
678
  begin
592
- page_dir = @page_dir.expand_path.relative_path_from @root
679
+ page_dir = page_dir.expand_path.relative_path_from @root
593
680
  rescue ArgumentError
594
681
  # On Windows, sometimes crosses different drive letters.
595
- page_dir = @page_dir.expand_path
682
+ page_dir = page_dir.expand_path
596
683
  end
597
684
 
598
685
  @page_dir = page_dir
@@ -627,7 +714,7 @@ class RDoc::Options
627
714
  ##
628
715
  # Parses command line options.
629
716
 
630
- def parse argv
717
+ def parse(argv)
631
718
  ignore_invalid = true
632
719
 
633
720
  argv.insert(0, *ENV['RDOCOPT'].split) if ENV['RDOCOPT']
@@ -666,7 +753,7 @@ Usage: #{opt.program_name} [options] [names...]
666
753
 
667
754
  EOF
668
755
 
669
- parsers = Hash.new { |h,parser| h[parser] = [] }
756
+ parsers = Hash.new { |h, parser| h[parser] = [] }
670
757
 
671
758
  RDoc::Parser.parsers.each do |regexp, parser|
672
759
  parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source
@@ -677,14 +764,6 @@ Usage: #{opt.program_name} [options] [names...]
677
764
  end
678
765
  opt.banner += " - TomDoc: Only in ruby files\n"
679
766
 
680
- opt.banner += "\n The following options are deprecated:\n\n"
681
-
682
- name_length = DEPRECATED.keys.sort_by { |k| k.length }.last.length
683
-
684
- DEPRECATED.sort_by { |k,| k }.each do |name, reason|
685
- opt.banner += " %*1$2$s %3$s\n" % [-name_length, name, reason]
686
- end
687
-
688
767
  opt.accept Template do |template|
689
768
  template_dir = template_dir_for template
690
769
 
@@ -766,6 +845,18 @@ Usage: #{opt.program_name} [options] [names...]
766
845
  @exclude << value
767
846
  end
768
847
 
848
+ opt.on("--[no-]apply-default-exclude",
849
+ "Use default PATTERN to exclude.") do |value|
850
+ @apply_default_exclude = value
851
+ end
852
+
853
+ opt.separator nil
854
+
855
+ opt.on("--no-skipping-tests", nil,
856
+ "Don't skip generating documentation for test and spec files") do |value|
857
+ @skip_tests = false
858
+ end
859
+
769
860
  opt.separator nil
770
861
 
771
862
  opt.on("--extension=NEW=OLD", "-E",
@@ -809,7 +900,7 @@ Usage: #{opt.program_name} [options] [names...]
809
900
 
810
901
  opt.separator nil
811
902
 
812
- opt.on("--visibility=VISIBILITY", "-V", RDoc::VISIBILITIES + [:nodoc],
903
+ opt.on("--visibility=VISIBILITY", RDoc::VISIBILITIES + [:nodoc],
813
904
  "Minimum visibility to document a method.",
814
905
  "One of 'public', 'protected' (the default),",
815
906
  "'private' or 'nodoc' (show everything)") do |value|
@@ -818,6 +909,14 @@ Usage: #{opt.program_name} [options] [names...]
818
909
 
819
910
  opt.separator nil
820
911
 
912
+ opt.on("--[no-]embed-mixins",
913
+ "Embed mixin methods, attributes, and constants",
914
+ "into class documentation. (default false)") do |value|
915
+ @embed_mixins = value
916
+ end
917
+
918
+ opt.separator nil
919
+
821
920
  markup_formats = RDoc::Text::MARKUP_FORMAT.keys.sort
822
921
 
823
922
  opt.on("--markup=MARKUP", markup_formats,
@@ -847,7 +946,7 @@ Usage: #{opt.program_name} [options] [names...]
847
946
  "such files at your project root.",
848
947
  "NOTE: Do not use the same file name in",
849
948
  "the page dir and the root of your project") do |page_dir|
850
- @page_dir = Pathname(page_dir)
949
+ @page_dir = page_dir
851
950
  end
852
951
 
853
952
  opt.separator nil
@@ -901,14 +1000,6 @@ Usage: #{opt.program_name} [options] [names...]
901
1000
  @op_dir = value
902
1001
  end
903
1002
 
904
- opt.separator nil
905
-
906
- opt.on("-d",
907
- "Deprecated --diagram option.",
908
- "Prevents firing debug mode",
909
- "with legacy invocation.") do |value|
910
- end
911
-
912
1003
  opt.separator nil
913
1004
  opt.separator 'HTML generator options:'
914
1005
  opt.separator nil
@@ -922,6 +1013,13 @@ Usage: #{opt.program_name} [options] [names...]
922
1013
 
923
1014
  opt.separator nil
924
1015
 
1016
+ opt.on("--autolink-excluded-words=WORDS", Array,
1017
+ "Words to be ignored in autolink cross-references") do |value|
1018
+ @autolink_excluded_words.concat value
1019
+ end
1020
+
1021
+ opt.separator nil
1022
+
925
1023
  opt.on("--hyperlink-all", "-A",
926
1024
  "Generate hyperlinks for all words that",
927
1025
  "correspond to known methods, even if they",
@@ -971,7 +1069,7 @@ Usage: #{opt.program_name} [options] [names...]
971
1069
  opt.on("--template-stylesheets=FILES", PathArray,
972
1070
  "Set (or add to) the list of files to",
973
1071
  "include with the html template.") do |value|
974
- @template_stylesheets << value
1072
+ @template_stylesheets.concat value
975
1073
  end
976
1074
 
977
1075
  opt.separator nil
@@ -1039,6 +1137,15 @@ Usage: #{opt.program_name} [options] [names...]
1039
1137
  opt.separator "Generic options:"
1040
1138
  opt.separator nil
1041
1139
 
1140
+ opt.on("--server[=PORT]", Integer,
1141
+ "Start a web server to preview",
1142
+ "documentation with live reload.",
1143
+ "Defaults to port 4000.") do |port|
1144
+ @server_port = port || 4000
1145
+ end
1146
+
1147
+ opt.separator nil
1148
+
1042
1149
  opt.on("--write-options",
1043
1150
  "Write .rdoc_options to the current",
1044
1151
  "directory with the given options. Not all",
@@ -1063,6 +1170,13 @@ Usage: #{opt.program_name} [options] [names...]
1063
1170
 
1064
1171
  opt.separator nil
1065
1172
 
1173
+ opt.on("--warn-missing-rdoc-ref",
1174
+ "Warn if rdoc-ref links can't be resolved") do |value|
1175
+ @warn_missing_rdoc_ref = value
1176
+ end
1177
+
1178
+ opt.separator nil
1179
+
1066
1180
  opt.on("--[no-]ignore-invalid",
1067
1181
  "Ignore invalid options and continue",
1068
1182
  "(default true).") do |value|
@@ -1104,18 +1218,12 @@ Usage: #{opt.program_name} [options] [names...]
1104
1218
  opt.separator nil
1105
1219
  end
1106
1220
 
1107
- setup_generator 'darkfish' if
1108
- argv.grep(/\A(-f|--fmt|--format|-r|-R|--ri|--ri-site)\b/).empty?
1109
-
1110
- deprecated = []
1111
1221
  invalid = []
1112
1222
 
1113
1223
  begin
1114
1224
  opts.parse! argv
1115
1225
  rescue OptionParser::ParseError => e
1116
- if DEPRECATED[e.args.first] then
1117
- deprecated << e.args.first
1118
- elsif %w[--format --ri -r --ri-site -R].include? e.args.first then
1226
+ if %w[--format --ri -r --ri-site -R].include? e.args.first then
1119
1227
  raise
1120
1228
  else
1121
1229
  invalid << e.args.join(' ')
@@ -1124,22 +1232,13 @@ Usage: #{opt.program_name} [options] [names...]
1124
1232
  retry
1125
1233
  end
1126
1234
 
1127
- unless @generator then
1128
- @generator = RDoc::Generator::Darkfish
1129
- @generator_name = 'darkfish'
1130
- end
1235
+ setup_generator unless @generator
1131
1236
 
1132
1237
  if @pipe and not argv.empty? then
1133
1238
  @pipe = false
1134
1239
  invalid << '-p (with files)'
1135
1240
  end
1136
1241
 
1137
- unless quiet then
1138
- deprecated.each do |opt|
1139
- $stderr.puts 'option ' + opt + ' is deprecated: ' + DEPRECATED[opt]
1140
- end
1141
- end
1142
-
1143
1242
  unless invalid.empty? then
1144
1243
  invalid = "invalid options: #{invalid.join ', '}"
1145
1244
 
@@ -1159,13 +1258,6 @@ Usage: #{opt.program_name} [options] [names...]
1159
1258
 
1160
1259
  @files = argv.dup
1161
1260
 
1162
- finish
1163
-
1164
- if @write_options then
1165
- write_options
1166
- exit
1167
- end
1168
-
1169
1261
  self
1170
1262
  end
1171
1263
 
@@ -1179,14 +1271,14 @@ Usage: #{opt.program_name} [options] [names...]
1179
1271
  ##
1180
1272
  # Set quietness to +bool+
1181
1273
 
1182
- def quiet= bool
1274
+ def quiet=(bool)
1183
1275
  @verbosity = bool ? 0 : 1
1184
1276
  end
1185
1277
 
1186
1278
  ##
1187
1279
  # Removes directories from +path+ that are outside the current directory
1188
1280
 
1189
- def sanitize_path path
1281
+ def sanitize_path(path)
1190
1282
  require 'pathname'
1191
1283
  dot = Pathname.new('.').expand_path
1192
1284
 
@@ -1213,7 +1305,7 @@ Usage: #{opt.program_name} [options] [names...]
1213
1305
  # the options instance. This allows generators to add custom options or set
1214
1306
  # default options.
1215
1307
 
1216
- def setup_generator generator_name = @generator_name
1308
+ def setup_generator(generator_name = @generator_name)
1217
1309
  @generator = @generators[generator_name]
1218
1310
 
1219
1311
  unless @generator then
@@ -1235,7 +1327,7 @@ Usage: #{opt.program_name} [options] [names...]
1235
1327
  ##
1236
1328
  # Finds the template dir for +template+
1237
1329
 
1238
- def template_dir_for template
1330
+ def template_dir_for(template)
1239
1331
  template_path = File.join 'rdoc', 'generator', 'template', template
1240
1332
 
1241
1333
  $LOAD_PATH.map do |path|
@@ -1252,7 +1344,7 @@ Usage: #{opt.program_name} [options] [names...]
1252
1344
  # When +:all+ is passed, visibility is set to +:private+, similarly to
1253
1345
  # RDOCOPT="--all", see #visibility for more information.
1254
1346
 
1255
- def visibility= visibility
1347
+ def visibility=(visibility)
1256
1348
  case visibility
1257
1349
  when :all
1258
1350
  @visibility = :private
@@ -1264,7 +1356,7 @@ Usage: #{opt.program_name} [options] [names...]
1264
1356
  ##
1265
1357
  # Displays a warning using Kernel#warn if we're being verbose
1266
1358
 
1267
- def warn message
1359
+ def warn(message)
1268
1360
  super message if @verbosity > 1
1269
1361
  end
1270
1362
 
@@ -1278,8 +1370,43 @@ Usage: #{opt.program_name} [options] [names...]
1278
1370
  File.open '.rdoc_options', 'w' do |io|
1279
1371
  io.set_encoding Encoding::UTF_8
1280
1372
 
1281
- YAML.dump self, io
1373
+ io.print to_yaml
1374
+ end
1375
+ end
1376
+
1377
+ ##
1378
+ # Loads options from .rdoc_options if the file exists, otherwise creates a
1379
+ # new RDoc::Options instance.
1380
+
1381
+ def self.load_options
1382
+ options_file = File.expand_path '.rdoc_options'
1383
+ return RDoc::Options.new unless File.exist? options_file
1384
+
1385
+ RDoc.load_yaml
1386
+
1387
+ content = File.read('.rdoc_options')
1388
+
1389
+ if defined?(Psych)
1390
+ begin
1391
+ options = Psych.safe_load content, 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
+ else
1396
+ options = RDoc.yaml_serializer.load(content)
1397
+ end
1398
+
1399
+ return RDoc::Options.new unless options # Allow empty file.
1400
+
1401
+ raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
1402
+ RDoc::Options === options or Hash === options
1403
+
1404
+ if Hash === options
1405
+ # Override the default values with the contents of YAML file.
1406
+ options = RDoc::Options.new options
1282
1407
  end
1408
+
1409
+ options
1283
1410
  end
1284
1411
 
1285
1412
  end