rdoc 6.9.1 → 6.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1941dad44ac3feaeea7befa661f56a2b58052b0c3fe14186593139234a5d14ee
4
- data.tar.gz: 85745f705a09ceb1039b8888fe853d617e5391949f9a5dde1d0cfa582a05c2b4
3
+ metadata.gz: 870fa0cb431cb2be4520001d6bceb293d36475e2d96e090d749a2ee7b91bb979
4
+ data.tar.gz: ea650e35d6b2fe0a33a031e8df70be62742d9046cf9ad9aca8d7ead3cac67038
5
5
  SHA512:
6
- metadata.gz: 2e4a0dd698c7f469b361ee4baf9acded0c4d202df288b026dce14adc79ef44912af00bb74ea7187ac973f6b26d34ca8041bdc2498b796e281b9f9f6a45cdab64
7
- data.tar.gz: 3ecac3e56d13bab06679d072813adc0091fad04a10b9a31ce12ff8137462557a1032a88ca3c42e0cc4d366ecf9e7d13002092605e202fb7dae55a286bfac18ae
6
+ metadata.gz: b3cc3a1797ce0a7538620e71b04f5db77eea9af380b6c8db05b283cc17f4b0504d096c33fac55f06c7004100a1d18217e154dcf4f24a7538167292746be9a16c
7
+ data.tar.gz: 0f52da54649752c27b2b330e6cda90aa9c478b8f4fd068b291666771d55e84db67a6c57f5261b4678260b93726eb4ec21c2728e706be0bfb37d1ad3277188330
@@ -18,6 +18,7 @@
18
18
  solo = top.one? {|klass| klass.display?}
19
19
  traverse = proc do |klasses| -%>
20
20
  <ul class="link-list">
21
+ <%- klasses.uniq!(&:full_name) -%>
21
22
  <%- klasses.each do |index_klass| -%>
22
23
  <%- if children = all_classes[index_klass.full_name] -%>
23
24
  <li><details<% if solo; solo = false %> open<% end %>><summary><% link.call(index_klass) %></summary>
@@ -103,6 +103,12 @@ function hookSidebar() {
103
103
  if (isSmallViewport) {
104
104
  navigation.hidden = true;
105
105
  navigationToggle.ariaExpanded = false;
106
+ document.addEventListener('click', (e) => {
107
+ if (e.target.closest('#navigation a')) {
108
+ navigation.hidden = true;
109
+ navigationToggle.ariaExpanded = false;
110
+ }
111
+ });
106
112
  }
107
113
  }
108
114
 
@@ -195,18 +195,20 @@ class RDoc::Markup::Formatter
195
195
  @in_tt > 0
196
196
  end
197
197
 
198
+ def tt_tag? attr_mask, reverse = false
199
+ each_attr_tag(attr_mask, reverse) do |tag|
200
+ return true if tt? tag
201
+ end
202
+ false
203
+ end
204
+
198
205
  ##
199
206
  # Turns on tags for +item+ on +res+
200
207
 
201
208
  def on_tags res, item
202
- attr_mask = item.turn_on
203
- return if attr_mask.zero?
204
-
205
- @attr_tags.each do |tag|
206
- if attr_mask & tag.bit != 0 then
207
- res << annotate(tag.on)
208
- @in_tt += 1 if tt? tag
209
- end
209
+ each_attr_tag(item.turn_on) do |tag|
210
+ res << annotate(tag.on)
211
+ @in_tt += 1 if tt? tag
210
212
  end
211
213
  end
212
214
 
@@ -214,13 +216,18 @@ class RDoc::Markup::Formatter
214
216
  # Turns off tags for +item+ on +res+
215
217
 
216
218
  def off_tags res, item
217
- attr_mask = item.turn_off
219
+ each_attr_tag(item.turn_off, true) do |tag|
220
+ @in_tt -= 1 if tt? tag
221
+ res << annotate(tag.off)
222
+ end
223
+ end
224
+
225
+ def each_attr_tag attr_mask, reverse = false
218
226
  return if attr_mask.zero?
219
227
 
220
- @attr_tags.reverse_each do |tag|
228
+ @attr_tags.public_send(reverse ? :reverse_each : :each) do |tag|
221
229
  if attr_mask & tag.bit != 0 then
222
- @in_tt -= 1 if tt? tag
223
- res << annotate(tag.off)
230
+ yield tag
224
231
  end
225
232
  end
226
233
  end
@@ -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
@@ -254,7 +254,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
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
data/lib/rdoc/options.rb CHANGED
@@ -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
 
@@ -349,18 +355,29 @@ class RDoc::Options
349
355
  # +--[no-]embed-mixins+ (Default is +false+.)
350
356
  attr_accessor :embed_mixins
351
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
+
352
366
  def initialize loaded_options = nil # :nodoc:
353
367
  init_ivars
354
368
  override loaded_options if loaded_options
355
369
  end
356
370
 
371
+ DEFAULT_EXCLUDE = %w[
372
+ ~\z \.orig\z \.rej\z \.bak\z
373
+ \.gemspec\z
374
+ ]
375
+
357
376
  def init_ivars # :nodoc:
377
+ @autolink_excluded_words = []
358
378
  @dry_run = false
359
379
  @embed_mixins = false
360
- @exclude = %w[
361
- ~\z \.orig\z \.rej\z \.bak\z
362
- \.gemspec\z
363
- ]
380
+ @exclude = []
364
381
  @files = nil
365
382
  @force_output = false
366
383
  @force_update = true
@@ -393,11 +410,13 @@ class RDoc::Options
393
410
  @update_output_dir = true
394
411
  @verbosity = 1
395
412
  @visibility = :protected
413
+ @warn_missing_rdoc_ref = true
396
414
  @webcvs = nil
397
415
  @write_options = false
398
416
  @encoding = Encoding::UTF_8
399
417
  @charset = @encoding.name
400
418
  @skip_tests = true
419
+ @apply_default_exclude = true
401
420
  end
402
421
 
403
422
  def init_with map # :nodoc:
@@ -424,6 +443,9 @@ class RDoc::Options
424
443
  @visibility = map['visibility']
425
444
  @webcvs = map['webcvs']
426
445
 
446
+ @apply_default_exclude = map['apply_default_exclude']
447
+ @autolink_excluded_words = map['autolink_excluded_words']
448
+
427
449
  @rdoc_include = sanitize_path map['rdoc_include']
428
450
  @static_path = sanitize_path map['static_path']
429
451
  end
@@ -456,6 +478,10 @@ class RDoc::Options
456
478
  @title = map['title'] if map.has_key?('title')
457
479
  @visibility = map['visibility'] if map.has_key?('visibility')
458
480
  @webcvs = map['webcvs'] if map.has_key?('webcvs')
481
+ @autolink_excluded_words = map['autolink_excluded_words'] if map.has_key?('autolink_excluded_words')
482
+ @apply_default_exclude = map['apply_default_exclude'] if map.has_key?('apply_default_exclude')
483
+
484
+ @warn_missing_rdoc_ref = map['warn_missing_rdoc_ref'] if map.has_key?('warn_missing_rdoc_ref')
459
485
 
460
486
  if map.has_key?('rdoc_include')
461
487
  @rdoc_include = sanitize_path map['rdoc_include']
@@ -484,7 +510,9 @@ class RDoc::Options
484
510
  @template == other.template and
485
511
  @title == other.title and
486
512
  @visibility == other.visibility and
487
- @webcvs == other.webcvs
513
+ @webcvs == other.webcvs and
514
+ @apply_default_exclude == other.apply_default_exclude and
515
+ @autolink_excluded_words == other.autolink_excluded_words
488
516
  end
489
517
 
490
518
  ##
@@ -555,10 +583,12 @@ class RDoc::Options
555
583
  if @exclude.nil? or Regexp === @exclude then
556
584
  # done, #finish is being re-run
557
585
  @exclude
558
- elsif @exclude.empty? then
586
+ elsif !@apply_default_exclude and @exclude.empty? then
559
587
  nil
560
588
  else
561
- Regexp.new(@exclude.join("|"))
589
+ exclude = @exclude
590
+ exclude |= DEFAULT_EXCLUDE if @apply_default_exclude
591
+ Regexp.new(exclude.join("|"))
562
592
  end
563
593
  end
564
594
 
@@ -792,6 +822,11 @@ Usage: #{opt.program_name} [options] [names...]
792
822
  @exclude << value
793
823
  end
794
824
 
825
+ opt.on("--[no-]apply-default-exclude",
826
+ "Use default PATTERN to exclude.") do |value|
827
+ @apply_default_exclude = value
828
+ end
829
+
795
830
  opt.separator nil
796
831
 
797
832
  opt.on("--no-skipping-tests", nil,
@@ -963,6 +998,13 @@ Usage: #{opt.program_name} [options] [names...]
963
998
 
964
999
  opt.separator nil
965
1000
 
1001
+ opt.on("--autolink-excluded-words=WORDS", Array,
1002
+ "Words to be ignored in autolink cross-references") do |value|
1003
+ @autolink_excluded_words.concat value
1004
+ end
1005
+
1006
+ opt.separator nil
1007
+
966
1008
  opt.on("--hyperlink-all", "-A",
967
1009
  "Generate hyperlinks for all words that",
968
1010
  "correspond to known methods, even if they",
@@ -1104,6 +1146,13 @@ Usage: #{opt.program_name} [options] [names...]
1104
1146
 
1105
1147
  opt.separator nil
1106
1148
 
1149
+ opt.on("--warn-missing-rdoc-ref",
1150
+ "Warn if rdoc-ref links can't be resolved") do |value|
1151
+ @warn_missing_rdoc_ref = value
1152
+ end
1153
+
1154
+ opt.separator nil
1155
+
1107
1156
  opt.on("--[no-]ignore-invalid",
1108
1157
  "Ignore invalid options and continue",
1109
1158
  "(default true).") do |value|
data/lib/rdoc/parser/c.rb CHANGED
@@ -405,6 +405,7 @@ class RDoc::Parser::C < RDoc::Parser
405
405
  \s*(.*?)\s*\)\s*;
406
406
  %xm) do |type, var_name, const_name, definition|
407
407
  var_name = "rb_cObject" if !var_name or var_name == "rb_mKernel"
408
+ type = "const" if type == "global_const"
408
409
  handle_constants type, var_name, const_name, definition
409
410
  end
410
411
 
@@ -760,6 +761,10 @@ class RDoc::Parser::C < RDoc::Parser
760
761
  rb_define_(?<type>\w+)\(\s*(?:\w+),\s*
761
762
  "(?<name>\w+)"\s*,
762
763
  .*?\)\s*;
764
+ | (?<doc>(?>^\s*/\*.*?\*/\s+))
765
+ rb_define_global_(?<type>const)\(\s*
766
+ "(?<name>\w+)"\s*,
767
+ .*?\)\s*;
763
768
  | (?<doc>(?>^\s*/\*.*?\*/\s+))
764
769
  rb_file_(?<type>const)\(\s*
765
770
  "(?<name>\w+)"\s*,
@@ -642,14 +642,16 @@ class RDoc::Parser::PrismRuby < RDoc::Parser
642
642
 
643
643
  owner, name = find_or_create_constant_owner_name(module_name)
644
644
  if is_class
645
- mod = owner.classes_hash[name] || owner.add_class(RDoc::NormalClass, name, superclass_name || '::Object')
646
-
647
645
  # RDoc::NormalClass resolves superclass name despite of the lack of module nesting information.
648
646
  # We need to fix it when RDoc::NormalClass resolved to a wrong constant name
649
647
  if superclass_name
650
648
  superclass_full_path = resolve_constant_path(superclass_name)
651
649
  superclass = @store.find_class_or_module(superclass_full_path) if superclass_full_path
652
650
  superclass_full_path ||= superclass_name
651
+ end
652
+ # add_class should be done after resolving superclass
653
+ mod = owner.classes_hash[name] || owner.add_class(RDoc::NormalClass, name, superclass_name || '::Object')
654
+ if superclass_name
653
655
  if superclass
654
656
  mod.superclass = superclass
655
657
  elsif mod.superclass.is_a?(String) && mod.superclass != superclass_full_path
@@ -181,10 +181,10 @@ class RDoc::RubyGemsHook
181
181
  options = ::RDoc::Options.new
182
182
  options.default_title = "#{@spec.full_name} Documentation"
183
183
  options.parse args
184
+ options.quiet = !Gem.configuration.really_verbose
185
+ options.finish
184
186
  end
185
187
 
186
- options.quiet = !Gem.configuration.really_verbose
187
-
188
188
  @rdoc = new_rdoc
189
189
  @rdoc.options = options
190
190
 
@@ -310,5 +310,21 @@ module RDoc
310
310
  # Generate document for compatibility if this is a default gem.
311
311
  RubyGemsHook.generate(installer, specs)
312
312
  end
313
+
314
+ def self.load_rdoc
315
+ RubyGemsHook.load_rdoc
316
+ end
317
+
318
+ def self.rdoc_version
319
+ RubyGemsHook.rdoc_version
320
+ end
321
+
322
+ def rdoc_installed?
323
+ RubyGemsHook.new(@spec).rdoc_installed?
324
+ end
325
+
326
+ def ri_installed?
327
+ RubyGemsHook.new(@spec).ri_installed?
328
+ end
313
329
  end
314
330
  end
data/lib/rdoc/version.rb CHANGED
@@ -5,6 +5,6 @@ module RDoc
5
5
  ##
6
6
  # RDoc version you are using
7
7
 
8
- VERSION = '6.9.1'
8
+ VERSION = '6.11.0'
9
9
 
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.9.1
4
+ version: 6.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
@@ -11,10 +11,9 @@ authors:
11
11
  - Zachary Scott
12
12
  - Hiroshi SHIBATA
13
13
  - ITOYANAGI Sakura
14
- autorequire:
15
14
  bindir: exe
16
15
  cert_chain: []
17
- date: 2024-12-16 00:00:00.000000000 Z
16
+ date: 2025-01-16 00:00:00.000000000 Z
18
17
  dependencies:
19
18
  - !ruby/object:Gem::Dependency
20
19
  name: psych
@@ -254,7 +253,6 @@ metadata:
254
253
  homepage_uri: https://ruby.github.io/rdoc
255
254
  source_code_uri: https://github.com/ruby/rdoc
256
255
  changelog_uri: https://github.com/ruby/rdoc/releases
257
- post_install_message:
258
256
  rdoc_options:
259
257
  - "--main"
260
258
  - README.rdoc
@@ -271,8 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
269
  - !ruby/object:Gem::Version
272
270
  version: '2.2'
273
271
  requirements: []
274
- rubygems_version: 3.5.11
275
- signing_key:
272
+ rubygems_version: 3.6.2
276
273
  specification_version: 4
277
274
  summary: RDoc produces HTML and command-line documentation for Ruby projects
278
275
  test_files: []