rdoc 6.12.0 → 6.13.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rdoc/code_object/alias.rb +2 -9
  3. data/lib/rdoc/code_object/any_method.rb +5 -10
  4. data/lib/rdoc/code_object/attr.rb +3 -6
  5. data/lib/rdoc/code_object/class_module.rb +23 -8
  6. data/lib/rdoc/code_object/context.rb +4 -46
  7. data/lib/rdoc/code_object/method_attr.rb +2 -22
  8. data/lib/rdoc/code_object/require.rb +1 -1
  9. data/lib/rdoc/code_object/top_level.rb +3 -23
  10. data/lib/rdoc/code_object.rb +3 -34
  11. data/lib/rdoc/comment.rb +1 -4
  12. data/lib/rdoc/generator/darkfish.rb +84 -96
  13. data/lib/rdoc/generator/json_index.rb +1 -17
  14. data/lib/rdoc/generator/markup.rb +2 -2
  15. data/lib/rdoc/generator/pot/message_extractor.rb +2 -2
  16. data/lib/rdoc/generator/pot.rb +0 -5
  17. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -30
  18. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +1 -1
  19. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +1 -1
  20. data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -0
  21. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +13 -0
  22. data/lib/rdoc/markdown.kpeg +7 -5
  23. data/lib/rdoc/markdown.rb +34 -21
  24. data/lib/rdoc/markup/heading.rb +7 -1
  25. data/lib/rdoc/markup/to_html.rb +6 -1
  26. data/lib/rdoc/parser/c.rb +4 -7
  27. data/lib/rdoc/parser/prism_ruby.rb +8 -15
  28. data/lib/rdoc/parser/ruby.rb +7 -10
  29. data/lib/rdoc/rdoc.rb +3 -18
  30. data/lib/rdoc/ri/driver.rb +11 -3
  31. data/lib/rdoc/rubygems_hook.rb +1 -7
  32. data/lib/rdoc/servlet.rb +8 -7
  33. data/lib/rdoc/stats.rb +2 -2
  34. data/lib/rdoc/store.rb +9 -13
  35. data/lib/rdoc/text.rb +2 -2
  36. data/lib/rdoc/version.rb +1 -1
  37. metadata +2 -4
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
@@ -289,21 +289,19 @@ class RDoc::Parser::PrismRuby < RDoc::Parser
289
289
 
290
290
  if attributes
291
291
  attributes.each do |attr|
292
- a = RDoc::Attr.new(@container, attr, rw, processed_comment)
292
+ a = RDoc::Attr.new(@container, attr, rw, processed_comment, singleton: @singleton)
293
293
  a.store = @store
294
294
  a.line = line_no
295
- a.singleton = @singleton
296
295
  record_location(a)
297
296
  @container.add_attribute(a)
298
297
  a.visibility = visibility
299
298
  end
300
299
  elsif line_no || node
301
300
  method_name ||= call_node_name_arguments(node).first if is_call_node
302
- meth = RDoc::AnyMethod.new(@container, method_name)
303
- meth.singleton = @singleton || singleton_method
301
+ meth = RDoc::AnyMethod.new(@container, method_name, singleton: @singleton || singleton_method)
304
302
  handle_consecutive_comment_directive(meth, comment)
305
303
  comment.normalize
306
- comment.extract_call_seq(meth)
304
+ meth.call_seq = comment.extract_call_seq
307
305
  meth.comment = comment
308
306
  if node
309
307
  tokens = visible_tokens_from_location(node.location)
@@ -316,7 +314,6 @@ class RDoc::Parser::PrismRuby < RDoc::Parser
316
314
  meth,
317
315
  line_no: line_no,
318
316
  visibility: visibility,
319
- singleton: @singleton || singleton_method,
320
317
  params: '()',
321
318
  calls_super: false,
322
319
  block_params: nil,
@@ -452,8 +449,7 @@ class RDoc::Parser::PrismRuby < RDoc::Parser
452
449
  comment = consecutive_comment(line_no)
453
450
  handle_consecutive_comment_directive(@container, comment)
454
451
  visibility = @container.find_method(old_name, @singleton)&.visibility || :public
455
- a = RDoc::Alias.new(nil, old_name, new_name, comment, @singleton)
456
- a.comment = comment
452
+ a = RDoc::Alias.new(nil, old_name, new_name, comment, singleton: @singleton)
457
453
  handle_modifier_directive(a, line_no)
458
454
  a.store = @store
459
455
  a.line = line_no
@@ -472,10 +468,9 @@ class RDoc::Parser::PrismRuby < RDoc::Parser
472
468
  return unless @container.document_children
473
469
 
474
470
  names.each do |symbol|
475
- a = RDoc::Attr.new(nil, symbol.to_s, rw, comment)
471
+ a = RDoc::Attr.new(nil, symbol.to_s, rw, comment, singleton: @singleton)
476
472
  a.store = @store
477
473
  a.line = line_no
478
- a.singleton = @singleton
479
474
  record_location(a)
480
475
  handle_modifier_directive(a, line_no)
481
476
  @container.add_attribute(a) if should_document?(a)
@@ -514,13 +509,13 @@ class RDoc::Parser::PrismRuby < RDoc::Parser
514
509
  return if @in_proc_block
515
510
 
516
511
  receiver = receiver_name ? find_or_create_module_path(receiver_name, receiver_fallback_type) : @container
517
- meth = RDoc::AnyMethod.new(nil, name)
512
+ meth = RDoc::AnyMethod.new(nil, name, singleton: singleton)
518
513
  if (comment = consecutive_comment(start_line))
519
514
  handle_consecutive_comment_directive(@container, comment)
520
515
  handle_consecutive_comment_directive(meth, comment)
521
516
 
522
517
  comment.normalize
523
- comment.extract_call_seq(meth)
518
+ meth.call_seq = comment.extract_call_seq
524
519
  meth.comment = comment
525
520
  end
526
521
  handle_modifier_directive(meth, start_line)
@@ -533,7 +528,6 @@ class RDoc::Parser::PrismRuby < RDoc::Parser
533
528
  meth,
534
529
  line_no: start_line,
535
530
  visibility: visibility,
536
- singleton: singleton,
537
531
  params: params,
538
532
  calls_super: calls_super,
539
533
  block_params: block_params,
@@ -553,12 +547,11 @@ class RDoc::Parser::PrismRuby < RDoc::Parser
553
547
  end
554
548
  end
555
549
 
556
- private def internal_add_method(container, meth, line_no:, visibility:, singleton:, params:, calls_super:, block_params:, tokens:) # :nodoc:
550
+ private def internal_add_method(container, meth, line_no:, visibility:, params:, calls_super:, block_params:, tokens:) # :nodoc:
557
551
  meth.name ||= meth.call_seq[/\A[^()\s]+/] if meth.call_seq
558
552
  meth.name ||= 'unknown'
559
553
  meth.store = @store
560
554
  meth.line = line_no
561
- meth.singleton = singleton
562
555
  container.add_method(meth) # should add after setting singleton and before setting visibility
563
556
  meth.visibility = visibility
564
557
  meth.params ||= params
@@ -293,7 +293,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
293
293
  # Creates a new attribute in +container+ with +name+.
294
294
 
295
295
  def create_attr container, single, name, rw, comment # :nodoc:
296
- att = RDoc::Attr.new get_tkread, name, rw, comment, single == SINGLE
296
+ att = RDoc::Attr.new get_tkread, name, rw, comment, singleton: single == SINGLE
297
297
  record_location att
298
298
 
299
299
  container.add_attribute att
@@ -792,8 +792,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
792
792
  return
793
793
  end
794
794
 
795
- al = RDoc::Alias.new(get_tkread, old_name, new_name, comment,
796
- single == SINGLE)
795
+ al = RDoc::Alias.new(get_tkread, old_name, new_name, comment, singleton: single == SINGLE)
797
796
  record_location al
798
797
  al.line = line_no
799
798
 
@@ -1153,7 +1152,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
1153
1152
  end
1154
1153
 
1155
1154
  comment.normalize
1156
- comment.extract_call_seq meth
1155
+ meth.call_seq = comment.extract_call_seq
1157
1156
 
1158
1157
  return unless meth.name
1159
1158
 
@@ -1358,10 +1357,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
1358
1357
 
1359
1358
  return unless name
1360
1359
 
1361
- meth = RDoc::MetaMethod.new get_tkread, name
1360
+ meth = RDoc::MetaMethod.new get_tkread, name, singleton: singleton
1362
1361
  record_location meth
1363
1362
  meth.line = line_no
1364
- meth.singleton = singleton
1365
1363
 
1366
1364
  remove_token_listener self
1367
1365
 
@@ -1417,7 +1415,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
1417
1415
 
1418
1416
  look_for_directives_in meth, comment
1419
1417
  comment.normalize
1420
- comment.extract_call_seq meth
1418
+ meth.call_seq = comment.extract_call_seq
1421
1419
 
1422
1420
  container.add_method meth
1423
1421
 
@@ -1461,9 +1459,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
1461
1459
 
1462
1460
  return unless name
1463
1461
 
1464
- meth = RDoc::AnyMethod.new get_tkread, name
1462
+ meth = RDoc::AnyMethod.new get_tkread, name, singleton: single == SINGLE ? true : singleton
1465
1463
  look_for_directives_in meth, comment
1466
- meth.singleton = single == SINGLE ? true : singleton
1467
1464
  if singleton
1468
1465
  # `current_line_visibility' is useless because it works against
1469
1466
  # the normal method named as same as the singleton method, after
@@ -1485,7 +1482,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
1485
1482
  parse_method_params_and_body container, single, meth, added_container
1486
1483
 
1487
1484
  comment.normalize
1488
- comment.extract_call_seq meth
1485
+ meth.call_seq = comment.extract_call_seq
1489
1486
 
1490
1487
  meth.comment = comment
1491
1488
 
data/lib/rdoc/rdoc.rb CHANGED
@@ -69,7 +69,7 @@ class RDoc::RDoc
69
69
  ##
70
70
  # The current documentation store
71
71
 
72
- attr_reader :store
72
+ attr_accessor :store
73
73
 
74
74
  ##
75
75
  # Add +klass+ that can generate output after parsing
@@ -208,15 +208,6 @@ option)
208
208
  last
209
209
  end
210
210
 
211
- ##
212
- # Sets the current documentation tree to +store+ and sets the store's rdoc
213
- # driver to this instance.
214
-
215
- def store= store
216
- @store = store
217
- @store.rdoc = self
218
- end
219
-
220
211
  ##
221
212
  # Update the flag file in an output directory.
222
213
 
@@ -450,8 +441,6 @@ The internal error was:
450
441
  # current directory, so make sure you're somewhere writable before invoking.
451
442
 
452
443
  def document options
453
- self.store = RDoc::Store.new
454
-
455
444
  if RDoc::Options === options then
456
445
  @options = options
457
446
  else
@@ -460,6 +449,8 @@ The internal error was:
460
449
  end
461
450
  @options.finish
462
451
 
452
+ @store = RDoc::Store.new(@options)
453
+
463
454
  if @options.pipe then
464
455
  handle_pipe
465
456
  exit
@@ -469,12 +460,6 @@ The internal error was:
469
460
  @last_modified = setup_output_dir @options.op_dir, @options.force_update
470
461
  end
471
462
 
472
- @store.encoding = @options.encoding
473
- @store.dry_run = @options.dry_run
474
- @store.main = @options.main_page
475
- @store.title = @options.title
476
- @store.path = @options.op_dir
477
-
478
463
  @start_time = Time.now
479
464
 
480
465
  @store.load_cache
@@ -420,7 +420,7 @@ or the PAGER environment variable.
420
420
  *options[:extra_doc_dirs]) do |path, type|
421
421
  @doc_dirs << path
422
422
 
423
- store = RDoc::RI::Store.new path, type
423
+ store = RDoc::RI::Store.new(RDoc::Options.new, path: path, type: type)
424
424
  store.load_cache
425
425
  @stores << store
426
426
  end
@@ -754,7 +754,7 @@ or the PAGER environment variable.
754
754
  complete_klass name, klass, selector, method, completions
755
755
  complete_method name, klass, selector, completions
756
756
 
757
- completions.sort.uniq
757
+ completions.uniq.select {|s| s.start_with? name }.sort
758
758
  end
759
759
 
760
760
  def complete_klass name, klass, selector, method, completions # :nodoc:
@@ -789,7 +789,15 @@ or the PAGER environment variable.
789
789
  completions << "#{klass}#{selector}"
790
790
  end
791
791
 
792
- completions.concat methods
792
+ methods.each do |klass_sel_method|
793
+ match = klass_sel_method.match(/^(.+)(#|\.|::)([^#.:]+)$/)
794
+ # match[2] is `::` for class method and `#` for instance method.
795
+ # To be consistent with old completion that completes `['Foo#i', 'Foo::c']` for `Foo.`,
796
+ # `.` should be a wildcard for both `#` and `::` here.
797
+ if match && match[2] == selector || selector == '.'
798
+ completions << match[1] + selector + match[3]
799
+ end
800
+ end
793
801
  end
794
802
  end
795
803
 
@@ -188,13 +188,7 @@ class RDoc::RubyGemsHook
188
188
  @rdoc = new_rdoc
189
189
  @rdoc.options = options
190
190
 
191
- store = RDoc::Store.new
192
- store.encoding = options.encoding
193
- store.dry_run = options.dry_run
194
- store.main = options.main_page
195
- store.title = options.title
196
-
197
- @rdoc.store = store
191
+ @rdoc.store = RDoc::Store.new(options)
198
192
 
199
193
  say "Parsing documentation for #{@spec.full_name}"
200
194
 
data/lib/rdoc/servlet.rb CHANGED
@@ -133,7 +133,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
133
133
  show_documentation req, res
134
134
  end
135
135
  rescue WEBrick::HTTPStatus::NotFound => e
136
- generator = generator_for RDoc::Store.new
136
+ generator = generator_for RDoc::Store.new(@options)
137
137
 
138
138
  not_found generator, req, res, e.message
139
139
  rescue WEBrick::HTTPStatus::Status
@@ -247,6 +247,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
247
247
  generator = RDoc::Generator::Darkfish.new store, @options
248
248
  generator.file_output = false
249
249
  generator.asset_rel_path = '..'
250
+ generator.setup
250
251
 
251
252
  rdoc = RDoc::RDoc.new
252
253
  rdoc.store = store
@@ -290,7 +291,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
290
291
  def installed_docs
291
292
  extra_counter = 0
292
293
  ri_paths.map do |path, type|
293
- store = RDoc::Store.new path, type
294
+ store = RDoc::Store.new(@options, path: path, type: type)
294
295
  exists = File.exist? store.cache_path
295
296
 
296
297
  case type
@@ -419,15 +420,15 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
419
420
  def store_for source_name
420
421
  case source_name
421
422
  when 'home' then
422
- RDoc::Store.new RDoc::RI::Paths.home_dir, :home
423
+ RDoc::Store.new(@options, path: RDoc::RI::Paths.home_dir, type: :home)
423
424
  when 'ruby' then
424
- RDoc::Store.new RDoc::RI::Paths.system_dir, :system
425
+ RDoc::Store.new(@options, path: RDoc::RI::Paths.system_dir, type: :system)
425
426
  when 'site' then
426
- RDoc::Store.new RDoc::RI::Paths.site_dir, :site
427
+ RDoc::Store.new(@options, path: RDoc::RI::Paths.site_dir, type: :site)
427
428
  when /\Aextra-(\d+)\z/ then
428
429
  index = $1.to_i - 1
429
430
  ri_dir = installed_docs[index][4]
430
- RDoc::Store.new ri_dir, :extra
431
+ RDoc::Store.new(@options, path: ri_dir, type: :extra)
431
432
  else
432
433
  ri_dir, type = ri_paths.find do |dir, dir_type|
433
434
  next unless dir_type == :gem
@@ -438,7 +439,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
438
439
  raise WEBrick::HTTPStatus::NotFound,
439
440
  "Could not find gem \"#{ERB::Util.html_escape(source_name)}\". Are you sure you installed it?" unless ri_dir
440
441
 
441
- store = RDoc::Store.new ri_dir, type
442
+ store = RDoc::Store.new(@options, path: ri_dir, type: type)
442
443
 
443
444
  return store if File.exist? store.cache_path
444
445
 
data/lib/rdoc/stats.rb CHANGED
@@ -261,7 +261,7 @@ class RDoc::Stats
261
261
 
262
262
  report = []
263
263
 
264
- cm.each_attribute do |attr|
264
+ cm.attributes.each do |attr|
265
265
  next if attr.documented?
266
266
  line = attr.line ? ":#{attr.line}" : nil
267
267
  report << " #{attr.definition} :#{attr.name} # in file #{attr.file.full_name}#{line}\n"
@@ -331,7 +331,7 @@ class RDoc::Stats
331
331
 
332
332
  report = []
333
333
 
334
- cm.each_constant do |constant|
334
+ cm.constants.each do |constant|
335
335
  # TODO constant aliases are listed in the summary but not reported
336
336
  # figure out what to do here
337
337
  next if constant.documented? || constant.is_alias_for
data/lib/rdoc/store.rb CHANGED
@@ -94,11 +94,7 @@ class RDoc::Store
94
94
 
95
95
  attr_accessor :path
96
96
 
97
- ##
98
- # The RDoc::RDoc driver for this parse tree. This allows classes consulting
99
- # the documentation tree to access user-set options, for example.
100
-
101
- attr_accessor :rdoc
97
+ attr_reader :options
102
98
 
103
99
  ##
104
100
  # Type of ri datastore this was loaded from. See RDoc::RI::Driver,
@@ -124,11 +120,11 @@ class RDoc::Store
124
120
  ##
125
121
  # Creates a new Store of +type+ that will load or save to +path+
126
122
 
127
- def initialize path = nil, type = nil
128
- @dry_run = false
129
- @encoding = nil
130
- @path = path
131
- @rdoc = nil
123
+ def initialize(options, path: nil, type: nil)
124
+ @options = options
125
+ @dry_run = options.dry_run
126
+ @encoding = options.encoding
127
+ @path = path || options.op_dir
132
128
  @type = type
133
129
 
134
130
  @cache = {
@@ -139,10 +135,10 @@ class RDoc::Store
139
135
  :c_singleton_class_variables => {},
140
136
  :encoding => @encoding,
141
137
  :instance_methods => {},
142
- :main => nil,
138
+ :main => options.main_page,
143
139
  :modules => [],
144
140
  :pages => [],
145
- :title => nil,
141
+ :title => options.title,
146
142
  }
147
143
 
148
144
  @classes_hash = {}
@@ -766,7 +762,7 @@ class RDoc::Store
766
762
  save_method klass, method
767
763
  end
768
764
 
769
- klass.each_attribute do |attribute|
765
+ klass.attributes.each do |attribute|
770
766
  save_method klass, attribute
771
767
  end
772
768
  end
data/lib/rdoc/text.rb CHANGED
@@ -99,8 +99,8 @@ module RDoc::Text
99
99
  # Requires the including class to implement #formatter
100
100
 
101
101
  def markup text
102
- if @store.rdoc.options
103
- locale = @store.rdoc.options.locale
102
+ if @store.options
103
+ locale = @store.options.locale
104
104
  else
105
105
  locale = nil
106
106
  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.12.0'
8
+ VERSION = '6.13.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.12.0
4
+ version: 6.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
@@ -13,7 +13,7 @@ authors:
13
13
  - ITOYANAGI Sakura
14
14
  bindir: exe
15
15
  cert_chain: []
16
- date: 2025-02-06 00:00:00.000000000 Z
16
+ date: 2025-03-23 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: psych
@@ -106,10 +106,8 @@ files:
106
106
  - lib/rdoc/generator/ri.rb
107
107
  - lib/rdoc/generator/template/darkfish/_footer.rhtml
108
108
  - lib/rdoc/generator/template/darkfish/_head.rhtml
109
- - lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml
110
109
  - lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml
111
110
  - lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml
112
- - lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml
113
111
  - lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml
114
112
  - lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml
115
113
  - lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml
@@ -1,19 +0,0 @@
1
- <%- if !svninfo.empty? then %>
2
- <div id="file-svninfo-section" class="nav-section">
3
- <h3>VCS Info</h3>
4
-
5
- <div class="section-body">
6
- <dl class="svninfo">
7
- <dt>Rev
8
- <dd><%= svninfo[:rev] %>
9
-
10
- <dt>Last Checked In
11
- <dd><%= svninfo[:commitdate].strftime('%Y-%m-%d %H:%M:%S') %>
12
- (<%= svninfo[:commitdelta] %> ago)
13
-
14
- <dt>Checked in by
15
- <dd><%= svninfo[:committer] %>
16
- </dl>
17
- </div>
18
- </div>
19
- <%- end -%>
@@ -1,9 +0,0 @@
1
- <div id="file-list-section" class="nav-section">
2
- <h3>Defined In</h3>
3
-
4
- <ul>
5
- <%- klass.in_files.each do |tl| -%>
6
- <li><%= h tl.relative_name %>
7
- <%- end -%>
8
- </ul>
9
- </div>