rdoc 6.7.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 (89) hide show
  1. checksums.yaml +4 -4
  2. data/ExampleMarkdown.md +2 -0
  3. data/ExampleRDoc.rdoc +2 -0
  4. data/History.rdoc +64 -62
  5. data/LICENSE.rdoc +2 -0
  6. data/README.rdoc +13 -0
  7. data/RI.md +842 -0
  8. data/TODO.rdoc +8 -7
  9. data/lib/rdoc/{alias.rb → code_object/alias.rb} +3 -10
  10. data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +7 -12
  11. data/lib/rdoc/{attr.rb → code_object/attr.rb} +4 -7
  12. data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +107 -20
  13. data/lib/rdoc/{constant.rb → code_object/constant.rb} +1 -1
  14. data/lib/rdoc/{context → code_object/context}/section.rb +10 -68
  15. data/lib/rdoc/{context.rb → code_object/context.rb} +4 -46
  16. data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +19 -27
  17. data/lib/rdoc/{require.rb → code_object/require.rb} +1 -1
  18. data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +10 -28
  19. data/lib/rdoc/code_object.rb +6 -32
  20. data/lib/rdoc/comment.rb +12 -5
  21. data/lib/rdoc/generator/darkfish.rb +121 -95
  22. data/lib/rdoc/generator/json_index.rb +1 -17
  23. data/lib/rdoc/generator/markup.rb +2 -2
  24. data/lib/rdoc/generator/pot/message_extractor.rb +3 -3
  25. data/lib/rdoc/generator/pot/po_entry.rb +1 -1
  26. data/lib/rdoc/generator/pot.rb +0 -5
  27. data/lib/rdoc/generator/template/darkfish/_head.rhtml +23 -0
  28. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -29
  29. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +1 -1
  30. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +1 -1
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +20 -11
  32. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +3 -8
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  34. data/lib/rdoc/generator/template/darkfish/class.rhtml +84 -43
  35. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +391 -397
  36. data/lib/rdoc/generator/template/darkfish/index.rhtml +11 -10
  37. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +24 -1
  38. data/lib/rdoc/generator/template/darkfish/page.rhtml +5 -5
  39. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +10 -8
  40. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +5 -2
  41. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +11 -0
  42. data/lib/rdoc/markdown.kpeg +8 -6
  43. data/lib/rdoc/markdown.rb +55 -32
  44. data/lib/rdoc/markup/attribute_manager.rb +2 -2
  45. data/lib/rdoc/markup/formatter.rb +19 -12
  46. data/lib/rdoc/markup/heading.rb +7 -1
  47. data/lib/rdoc/markup/pre_process.rb +26 -6
  48. data/lib/rdoc/markup/to_bs.rb +1 -1
  49. data/lib/rdoc/markup/to_html.rb +7 -2
  50. data/lib/rdoc/markup/to_html_crossref.rb +63 -12
  51. data/lib/rdoc/markup/to_rdoc.rb +5 -5
  52. data/lib/rdoc/markup.rb +18 -13
  53. data/lib/rdoc/options.rb +90 -12
  54. data/lib/rdoc/parser/c.rb +30 -9
  55. data/lib/rdoc/parser/changelog.rb +5 -4
  56. data/lib/rdoc/parser/prism_ruby.rb +1092 -0
  57. data/lib/rdoc/parser/ripper_state_lex.rb +7 -305
  58. data/lib/rdoc/parser/ruby.rb +23 -17
  59. data/lib/rdoc/parser/simple.rb +1 -1
  60. data/lib/rdoc/parser.rb +5 -4
  61. data/lib/rdoc/rd/block_parser.rb +3 -3
  62. data/lib/rdoc/rd/inline_parser.rb +3 -3
  63. data/lib/rdoc/rdoc.rb +9 -21
  64. data/lib/rdoc/ri/driver.rb +85 -32
  65. data/lib/rdoc/rubygems_hook.rb +91 -15
  66. data/lib/rdoc/servlet.rb +8 -7
  67. data/lib/rdoc/stats.rb +2 -2
  68. data/lib/rdoc/store.rb +21 -13
  69. data/lib/rdoc/task.rb +2 -3
  70. data/lib/rdoc/text.rb +2 -2
  71. data/lib/rdoc/tom_doc.rb +1 -7
  72. data/lib/rdoc/version.rb +1 -1
  73. data/lib/rdoc.rb +22 -24
  74. data/lib/rubygems_plugin.rb +23 -0
  75. metadata +27 -28
  76. data/RI.rdoc +0 -57
  77. data/lib/rdoc/generator/template/darkfish/.document +0 -0
  78. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
  79. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
  80. data/lib/rdoc/generator/template/json_index/.document +0 -1
  81. /data/lib/rdoc/{anon_class.rb → code_object/anon_class.rb} +0 -0
  82. /data/lib/rdoc/{extend.rb → code_object/extend.rb} +0 -0
  83. /data/lib/rdoc/{ghost_method.rb → code_object/ghost_method.rb} +0 -0
  84. /data/lib/rdoc/{include.rb → code_object/include.rb} +0 -0
  85. /data/lib/rdoc/{meta_method.rb → code_object/meta_method.rb} +0 -0
  86. /data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +0 -0
  87. /data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +0 -0
  88. /data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +0 -0
  89. /data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +0 -0
@@ -58,7 +58,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
58
58
  # Creates a link to the reference +name+ if the name exists. If +text+ is
59
59
  # given it is used as the link text, otherwise +name+ is used.
60
60
 
61
- def cross_reference name, text = nil, code = true
61
+ def cross_reference name, text = nil, code = true, rdoc_ref: false
62
62
  lookup = name
63
63
 
64
64
  name = name[1..-1] unless @show_hash if name[0, 1] == '#'
@@ -70,7 +70,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
70
70
  text ||= name
71
71
  end
72
72
 
73
- link lookup, text, code
73
+ link lookup, text, code, rdoc_ref: rdoc_ref
74
74
  end
75
75
 
76
76
  ##
@@ -83,6 +83,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
83
83
  def handle_regexp_CROSSREF(target)
84
84
  name = target.text
85
85
 
86
+ return name if @options.autolink_excluded_words&.include?(name)
87
+
86
88
  return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails
87
89
 
88
90
  unless @hyperlink_all then
@@ -92,7 +94,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
92
94
  return name if name =~ /\A[a-z]*\z/
93
95
  end
94
96
 
95
- cross_reference name
97
+ cross_reference name, rdoc_ref: false
96
98
  end
97
99
 
98
100
  ##
@@ -100,9 +102,14 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
100
102
  # handle other schemes.
101
103
 
102
104
  def handle_regexp_HYPERLINK target
103
- return cross_reference $' if target.text =~ /\Ardoc-ref:/
105
+ url = target.text
104
106
 
105
- super
107
+ case url
108
+ when /\Ardoc-ref:/
109
+ cross_reference $', rdoc_ref: true
110
+ else
111
+ super
112
+ end
106
113
  end
107
114
 
108
115
  ##
@@ -117,8 +124,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
117
124
  url = target.text
118
125
 
119
126
  case url
120
- when /\Ardoc-ref:/ then
121
- cross_reference $'
127
+ when /\Ardoc-ref:/
128
+ cross_reference $', rdoc_ref: true
122
129
  else
123
130
  super
124
131
  end
@@ -129,16 +136,18 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
129
136
  # RDoc::Markup::ToHtml to handle other schemes.
130
137
 
131
138
  def gen_url url, text
132
- return super unless url =~ /\Ardoc-ref:/
133
-
134
- name = $'
135
- cross_reference name, text, name == text
139
+ if url =~ /\Ardoc-ref:/
140
+ name = $'
141
+ cross_reference name, text, name == text, rdoc_ref: true
142
+ else
143
+ super
144
+ end
136
145
  end
137
146
 
138
147
  ##
139
148
  # Creates an HTML link to +name+ with the given +text+.
140
149
 
141
- def link name, text, code = true
150
+ def link name, text, code = true, rdoc_ref: false
142
151
  if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])?@/
143
152
  name = $1
144
153
  label = $'
@@ -148,6 +157,9 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
148
157
 
149
158
  case ref
150
159
  when String then
160
+ if rdoc_ref && @options.warn_missing_rdoc_ref
161
+ puts "#{@from_path}: `rdoc-ref:#{name}` can't be resolved for `#{text}`"
162
+ end
151
163
  ref
152
164
  else
153
165
  path = ref ? ref.as_href(@from_path) : +""
@@ -172,4 +184,43 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
172
184
  end
173
185
  end
174
186
 
187
+ def convert_flow(flow)
188
+ res = []
189
+
190
+ i = 0
191
+ while i < flow.size
192
+ item = flow[i]
193
+ i += 1
194
+ case item
195
+ when RDoc::Markup::AttrChanger then
196
+ # Make "+Class#method+" a cross reference
197
+ if tt_tag?(item.turn_on) and
198
+ String === (str = flow[i]) and
199
+ RDoc::Markup::AttrChanger === flow[i+1] and
200
+ tt_tag?(flow[i+1].turn_off, true) and
201
+ (@options.hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP).match?(str) and
202
+ (text = cross_reference str) != str
203
+ then
204
+ text = yield text, res if defined?(yield)
205
+ res << text
206
+ i += 2
207
+ next
208
+ end
209
+ off_tags res, item
210
+ on_tags res, item
211
+ when String then
212
+ text = convert_string(item)
213
+ text = yield text, res if defined?(yield)
214
+ res << text
215
+ when RDoc::Markup::RegexpHandling then
216
+ text = convert_regexp_handling(item)
217
+ text = yield text, res if defined?(yield)
218
+ res << text
219
+ else
220
+ raise "Unknown flow element: #{item.inspect}"
221
+ end
222
+ end
223
+
224
+ res.join('')
225
+ end
175
226
  end
@@ -249,12 +249,12 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
249
249
  # Adds +table+ to the output
250
250
 
251
251
  def accept_table header, body, aligns
252
- widths = header.zip(body) do |h, b|
253
- [h.size, b.size].max
252
+ widths = header.zip(*body).map do |cols|
253
+ cols.map(&:size).max
254
254
  end
255
255
  aligns = aligns.map do |a|
256
256
  case a
257
- when nil
257
+ when nil, :center
258
258
  :center
259
259
  when :left
260
260
  :ljust
@@ -262,12 +262,12 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
262
262
  :rjust
263
263
  end
264
264
  end
265
- @res << header.zip(widths, aligns) do |h, w, a|
265
+ @res << header.zip(widths, aligns).map do |h, w, a|
266
266
  h.__send__(a, w)
267
267
  end.join("|").rstrip << "\n"
268
268
  @res << widths.map {|w| "-" * w }.join("|") << "\n"
269
269
  body.each do |row|
270
- @res << row.zip(widths, aligns) do |t, w, a|
270
+ @res << row.zip(widths, aligns).map do |t, w, a|
271
271
  t.__send__(a, w)
272
272
  end.join("|").rstrip << "\n"
273
273
  end
data/lib/rdoc/markup.rb CHANGED
@@ -10,19 +10,24 @@
10
10
  # RDoc::Markup and other markup formats do no output formatting, this is
11
11
  # handled by the RDoc::Markup::Formatter subclasses.
12
12
  #
13
- # = Supported Formats
14
- #
15
- # Besides the RDoc::Markup format, the following formats are built in to RDoc:
16
- #
17
- # markdown::
18
- # The markdown format as described by
19
- # http://daringfireball.net/projects/markdown/. See RDoc::Markdown for
20
- # details on the parser and supported extensions.
21
- # rd::
22
- # The rdtool format. See RDoc::RD for details on the parser and format.
23
- # tomdoc::
24
- # The TomDoc format as described by http://tomdoc.org/. See RDoc::TomDoc
25
- # for details on the parser and supported extensions.
13
+ # = Markup Formats
14
+ #
15
+ # +RDoc+ supports these markup formats:
16
+ #
17
+ # - +rdoc+:
18
+ # the +RDoc+ markup format;
19
+ # see RDoc::MarkupReference.
20
+ # - +markdown+:
21
+ # The +markdown+ markup format as described in
22
+ # the {Markdown Guide}[https://www.markdownguide.org];
23
+ # see RDoc::Markdown.
24
+ # - +rd+:
25
+ # the +rd+ markup format format;
26
+ # see RDoc::RD.
27
+ # - +tomdoc+:
28
+ # the TomDoc format as described in
29
+ # {TomDoc for Ruby}[http://tomdoc.org];
30
+ # see RDoc::TomDoc.
26
31
  #
27
32
  # You can choose a markup format using the following methods:
28
33
  #
data/lib/rdoc/options.rb CHANGED
@@ -233,9 +233,9 @@ class RDoc::Options
233
233
  attr_accessor :main_page
234
234
 
235
235
  ##
236
- # The default markup format. The default is 'rdoc'. 'markdown', 'tomdoc'
237
- # and 'rd' are also built-in.
238
-
236
+ # The markup format.
237
+ # One of: +rdoc+ (the default), +markdown+, +rd+, +tomdoc+.
238
+ # See {Markup Formats}[rdoc-ref:RDoc::Markup@Markup+Formats].
239
239
  attr_accessor :markup
240
240
 
241
241
  ##
@@ -325,6 +325,12 @@ class RDoc::Options
325
325
 
326
326
  attr_accessor :verbosity
327
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
+
328
334
  ##
329
335
  # URL of web cvs frontend
330
336
 
@@ -344,17 +350,44 @@ class RDoc::Options
344
350
  # Indicates if files of test suites should be skipped
345
351
  attr_accessor :skip_tests
346
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
+
347
376
  def initialize loaded_options = nil # :nodoc:
348
377
  init_ivars
349
378
  override loaded_options if loaded_options
350
379
  end
351
380
 
381
+ DEFAULT_EXCLUDE = %w[
382
+ ~\z \.orig\z \.rej\z \.bak\z
383
+ \.gemspec\z
384
+ ]
385
+
352
386
  def init_ivars # :nodoc:
387
+ @autolink_excluded_words = []
353
388
  @dry_run = false
354
- @exclude = %w[
355
- ~\z \.orig\z \.rej\z \.bak\z
356
- \.gemspec\z
357
- ]
389
+ @embed_mixins = false
390
+ @exclude = []
358
391
  @files = nil
359
392
  @force_output = false
360
393
  @force_update = true
@@ -387,11 +420,15 @@ class RDoc::Options
387
420
  @update_output_dir = true
388
421
  @verbosity = 1
389
422
  @visibility = :protected
423
+ @warn_missing_rdoc_ref = true
390
424
  @webcvs = nil
391
425
  @write_options = false
392
426
  @encoding = Encoding::UTF_8
393
427
  @charset = @encoding.name
394
428
  @skip_tests = true
429
+ @apply_default_exclude = true
430
+ @class_module_path_prefix = nil
431
+ @file_path_prefix = nil
395
432
  end
396
433
 
397
434
  def init_with map # :nodoc:
@@ -401,6 +438,7 @@ class RDoc::Options
401
438
  @encoding = encoding ? Encoding.find(encoding) : encoding
402
439
 
403
440
  @charset = map['charset']
441
+ @embed_mixins = map['embed_mixins']
404
442
  @exclude = map['exclude']
405
443
  @generator_name = map['generator_name']
406
444
  @hyperlink_all = map['hyperlink_all']
@@ -417,6 +455,9 @@ class RDoc::Options
417
455
  @visibility = map['visibility']
418
456
  @webcvs = map['webcvs']
419
457
 
458
+ @apply_default_exclude = map['apply_default_exclude']
459
+ @autolink_excluded_words = map['autolink_excluded_words']
460
+
420
461
  @rdoc_include = sanitize_path map['rdoc_include']
421
462
  @static_path = sanitize_path map['static_path']
422
463
  end
@@ -432,6 +473,7 @@ class RDoc::Options
432
473
  end
433
474
 
434
475
  @charset = map['charset'] if map.has_key?('charset')
476
+ @embed_mixins = map['embed_mixins'] if map.has_key?('embed_mixins')
435
477
  @exclude = map['exclude'] if map.has_key?('exclude')
436
478
  @generator_name = map['generator_name'] if map.has_key?('generator_name')
437
479
  @hyperlink_all = map['hyperlink_all'] if map.has_key?('hyperlink_all')
@@ -448,6 +490,10 @@ class RDoc::Options
448
490
  @title = map['title'] if map.has_key?('title')
449
491
  @visibility = map['visibility'] if map.has_key?('visibility')
450
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')
451
497
 
452
498
  if map.has_key?('rdoc_include')
453
499
  @rdoc_include = sanitize_path map['rdoc_include']
@@ -460,11 +506,12 @@ class RDoc::Options
460
506
  def == other # :nodoc:
461
507
  self.class === other and
462
508
  @encoding == other.encoding and
509
+ @embed_mixins == other.embed_mixins and
463
510
  @generator_name == other.generator_name and
464
511
  @hyperlink_all == other.hyperlink_all and
465
512
  @line_numbers == other.line_numbers and
466
513
  @locale == other.locale and
467
- @locale_dir == other.locale_dir and
514
+ @locale_dir == other.locale_dir and
468
515
  @main_page == other.main_page and
469
516
  @markup == other.markup and
470
517
  @op_dir == other.op_dir and
@@ -475,7 +522,9 @@ class RDoc::Options
475
522
  @template == other.template and
476
523
  @title == other.title and
477
524
  @visibility == other.visibility and
478
- @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
479
528
  end
480
529
 
481
530
  ##
@@ -546,10 +595,12 @@ class RDoc::Options
546
595
  if @exclude.nil? or Regexp === @exclude then
547
596
  # done, #finish is being re-run
548
597
  @exclude
549
- elsif @exclude.empty? then
598
+ elsif !@apply_default_exclude and @exclude.empty? then
550
599
  nil
551
600
  else
552
- Regexp.new(@exclude.join("|"))
601
+ exclude = @exclude
602
+ exclude |= DEFAULT_EXCLUDE if @apply_default_exclude
603
+ Regexp.new(exclude.join("|"))
553
604
  end
554
605
  end
555
606
 
@@ -683,7 +734,7 @@ Usage: #{opt.program_name} [options] [names...]
683
734
 
684
735
  EOF
685
736
 
686
- parsers = Hash.new { |h,parser| h[parser] = [] }
737
+ parsers = Hash.new { |h, parser| h[parser] = [] }
687
738
 
688
739
  RDoc::Parser.parsers.each do |regexp, parser|
689
740
  parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source
@@ -783,6 +834,11 @@ Usage: #{opt.program_name} [options] [names...]
783
834
  @exclude << value
784
835
  end
785
836
 
837
+ opt.on("--[no-]apply-default-exclude",
838
+ "Use default PATTERN to exclude.") do |value|
839
+ @apply_default_exclude = value
840
+ end
841
+
786
842
  opt.separator nil
787
843
 
788
844
  opt.on("--no-skipping-tests", nil,
@@ -842,6 +898,14 @@ Usage: #{opt.program_name} [options] [names...]
842
898
 
843
899
  opt.separator nil
844
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
+
845
909
  markup_formats = RDoc::Text::MARKUP_FORMAT.keys.sort
846
910
 
847
911
  opt.on("--markup=MARKUP", markup_formats,
@@ -946,6 +1010,13 @@ Usage: #{opt.program_name} [options] [names...]
946
1010
 
947
1011
  opt.separator nil
948
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
+
949
1020
  opt.on("--hyperlink-all", "-A",
950
1021
  "Generate hyperlinks for all words that",
951
1022
  "correspond to known methods, even if they",
@@ -1087,6 +1158,13 @@ Usage: #{opt.program_name} [options] [names...]
1087
1158
 
1088
1159
  opt.separator nil
1089
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
+
1090
1168
  opt.on("--[no-]ignore-invalid",
1091
1169
  "Ignore invalid options and continue",
1092
1170
  "(default true).") do |value|
data/lib/rdoc/parser/c.rb CHANGED
@@ -168,7 +168,7 @@ class RDoc::Parser::C < RDoc::Parser
168
168
  # Prepares for parsing a C file. See RDoc::Parser#initialize for details on
169
169
  # the arguments.
170
170
 
171
- def initialize top_level, file_name, content, options, stats
171
+ def initialize top_level, content, options, stats
172
172
  super
173
173
 
174
174
  @known_classes = RDoc::KNOWN_CLASSES.dup
@@ -248,9 +248,7 @@ class RDoc::Parser::C < RDoc::Parser
248
248
  # method that reference the same function.
249
249
 
250
250
  def add_alias(var_name, class_obj, old_name, new_name, comment)
251
- al = RDoc::Alias.new '', old_name, new_name, ''
252
- al.singleton = @singleton_classes.key? var_name
253
- al.comment = comment
251
+ al = RDoc::Alias.new '', old_name, new_name, comment, singleton: @singleton_classes.key?(var_name)
254
252
  al.record_location @top_level
255
253
  class_obj.add_alias al
256
254
  @stats.add_alias al
@@ -405,6 +403,7 @@ class RDoc::Parser::C < RDoc::Parser
405
403
  \s*(.*?)\s*\)\s*;
406
404
  %xm) do |type, var_name, const_name, definition|
407
405
  var_name = "rb_cObject" if !var_name or var_name == "rb_mKernel"
406
+ type = "const" if type == "global_const"
408
407
  handle_constants type, var_name, const_name, definition
409
408
  end
410
409
 
@@ -440,7 +439,7 @@ class RDoc::Parser::C < RDoc::Parser
440
439
  # Scans #content for rb_include_module
441
440
 
442
441
  def do_includes
443
- @content.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
442
+ @content.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c, m|
444
443
  next unless cls = @classes[c]
445
444
  m = @known_classes[m] || m
446
445
 
@@ -760,6 +759,10 @@ class RDoc::Parser::C < RDoc::Parser
760
759
  rb_define_(?<type>\w+)\(\s*(?:\w+),\s*
761
760
  "(?<name>\w+)"\s*,
762
761
  .*?\)\s*;
762
+ | (?<doc>(?>^\s*/\*.*?\*/\s+))
763
+ rb_define_global_(?<type>const)\(\s*
764
+ "(?<name>\w+)"\s*,
765
+ .*?\)\s*;
763
766
  | (?<doc>(?>^\s*/\*.*?\*/\s+))
764
767
  rb_file_(?<type>const)\(\s*
765
768
  "(?<name>\w+)"\s*,
@@ -805,7 +808,7 @@ class RDoc::Parser::C < RDoc::Parser
805
808
 
806
809
  def find_modifiers comment, meth_obj
807
810
  comment.normalize
808
- comment.extract_call_seq meth_obj
811
+ meth_obj.call_seq = comment.extract_call_seq
809
812
 
810
813
  look_for_directives_in meth_obj, comment
811
814
  end
@@ -1010,10 +1013,9 @@ class RDoc::Parser::C < RDoc::Parser
1010
1013
  type = 'method' # force public
1011
1014
  end
1012
1015
 
1013
- meth_obj = RDoc::AnyMethod.new '', meth_name
1016
+ singleton = singleton || %w[singleton_method module_function].include?(type)
1017
+ meth_obj = RDoc::AnyMethod.new '', meth_name, singleton: singleton
1014
1018
  meth_obj.c_function = function
1015
- meth_obj.singleton =
1016
- singleton || %w[singleton_method module_function].include?(type)
1017
1019
 
1018
1020
  p_count = Integer(param_count) rescue -1
1019
1021
 
@@ -1097,15 +1099,34 @@ class RDoc::Parser::C < RDoc::Parser
1097
1099
  # */
1098
1100
  #
1099
1101
  # This method modifies the +comment+
1102
+ # Both :main: and :title: directives are deprecated and will be removed in RDoc 7.
1100
1103
 
1101
1104
  def look_for_directives_in context, comment
1102
1105
  @preprocess.handle comment, context do |directive, param|
1103
1106
  case directive
1104
1107
  when 'main' then
1105
1108
  @options.main_page = param
1109
+
1110
+ warn <<~MSG
1111
+ The :main: directive is deprecated and will be removed in RDoc 7.
1112
+
1113
+ You can use these options to specify the initial page displayed instead:
1114
+ - `--main=#{param}` via the command line
1115
+ - `rdoc.main = "#{param}"` if you use `RDoc::Task`
1116
+ - `main_page: #{param}` in your `.rdoc_options` file
1117
+ MSG
1106
1118
  ''
1107
1119
  when 'title' then
1108
1120
  @options.default_title = param if @options.respond_to? :default_title=
1121
+
1122
+ warn <<~MSG
1123
+ The :title: directive is deprecated and will be removed in RDoc 7.
1124
+
1125
+ You can use these options to specify the title displayed instead:
1126
+ - `--title=#{param}` via the command line
1127
+ - `rdoc.title = "#{param}"` if you use `RDoc::Task`
1128
+ - `title: #{param}` in your `.rdoc_options` file
1129
+ MSG
1109
1130
  ''
1110
1131
  end
1111
1132
  end
@@ -193,7 +193,7 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
193
193
 
194
194
  entries << [entry_name, entry_body] if entry_name
195
195
 
196
- entries.reject! do |(entry,_)|
196
+ entries.reject! do |(entry, _)|
197
197
  entry == nil
198
198
  end
199
199
 
@@ -210,8 +210,9 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
210
210
  grouped_entries = group_entries entries
211
211
 
212
212
  doc = create_document grouped_entries
213
-
214
- @top_level.comment = doc
213
+ comment = RDoc::Comment.new(@content)
214
+ comment.document = doc
215
+ @top_level.comment = comment
215
216
 
216
217
  @top_level
217
218
  end
@@ -221,7 +222,7 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
221
222
 
222
223
  module Git
223
224
  ##
224
- # Parses auxiliary info. Currentry `base-url` to expand
225
+ # Parses auxiliary info. Currently `base-url` to expand
225
226
  # references is effective.
226
227
 
227
228
  def parse_info(info)