rdoc 6.11.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 (45) 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 +7 -12
  4. data/lib/rdoc/code_object/attr.rb +4 -7
  5. data/lib/rdoc/code_object/class_module.rb +37 -19
  6. data/lib/rdoc/code_object/constant.rb +1 -1
  7. data/lib/rdoc/code_object/context/section.rb +10 -68
  8. data/lib/rdoc/code_object/context.rb +4 -46
  9. data/lib/rdoc/code_object/method_attr.rb +2 -22
  10. data/lib/rdoc/code_object/require.rb +1 -1
  11. data/lib/rdoc/code_object/top_level.rb +4 -24
  12. data/lib/rdoc/code_object.rb +3 -35
  13. data/lib/rdoc/comment.rb +12 -5
  14. data/lib/rdoc/generator/darkfish.rb +92 -108
  15. data/lib/rdoc/generator/json_index.rb +1 -17
  16. data/lib/rdoc/generator/markup.rb +2 -2
  17. data/lib/rdoc/generator/pot/message_extractor.rb +2 -2
  18. data/lib/rdoc/generator/pot.rb +0 -5
  19. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -30
  20. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +1 -1
  21. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +1 -1
  22. data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -0
  23. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +13 -0
  24. data/lib/rdoc/generator/template/darkfish/index.rhtml +4 -4
  25. data/lib/rdoc/markdown.kpeg +7 -5
  26. data/lib/rdoc/markdown.rb +34 -21
  27. data/lib/rdoc/markup/heading.rb +7 -1
  28. data/lib/rdoc/markup/to_html.rb +6 -1
  29. data/lib/rdoc/parser/c.rb +5 -8
  30. data/lib/rdoc/parser/changelog.rb +3 -2
  31. data/lib/rdoc/parser/prism_ruby.rb +109 -45
  32. data/lib/rdoc/parser/ruby.rb +8 -11
  33. data/lib/rdoc/parser/simple.rb +1 -1
  34. data/lib/rdoc/parser.rb +3 -3
  35. data/lib/rdoc/rdoc.rb +3 -18
  36. data/lib/rdoc/ri/driver.rb +28 -19
  37. data/lib/rdoc/rubygems_hook.rb +1 -7
  38. data/lib/rdoc/servlet.rb +8 -7
  39. data/lib/rdoc/stats.rb +2 -2
  40. data/lib/rdoc/store.rb +9 -13
  41. data/lib/rdoc/text.rb +2 -2
  42. data/lib/rdoc/version.rb +1 -1
  43. metadata +2 -4
  44. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
@@ -14,7 +14,7 @@ class RDoc::Parser::Simple < RDoc::Parser
14
14
  ##
15
15
  # Prepare to parse a plain file
16
16
 
17
- def initialize(top_level, file_name, content, options, stats)
17
+ def initialize(top_level, content, options, stats)
18
18
  super
19
19
 
20
20
  preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include
data/lib/rdoc/parser.rb CHANGED
@@ -191,7 +191,7 @@ class RDoc::Parser
191
191
 
192
192
  content = remove_modeline content
193
193
 
194
- parser.new top_level, file_name, content, options, stats
194
+ parser.new top_level, content, options, stats
195
195
  rescue SystemCallError
196
196
  nil
197
197
  end
@@ -252,12 +252,12 @@ class RDoc::Parser
252
252
  # RDoc::Markup::PreProcess object is created which allows processing of
253
253
  # directives.
254
254
 
255
- def initialize top_level, file_name, content, options, stats
255
+ def initialize top_level, content, options, stats
256
256
  @top_level = top_level
257
257
  @top_level.parser = self.class
258
258
  @store = @top_level.store
259
259
 
260
- @file_name = file_name
260
+ @file_name = top_level.absolute_name
261
261
  @content = content
262
262
  @options = options
263
263
  @stats = stats
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
@@ -518,7 +518,7 @@ or the PAGER environment variable.
518
518
  with.each do |incl|
519
519
  out << RDoc::Markup::Paragraph.new(incl.name)
520
520
  out << RDoc::Markup::BlankLine.new
521
- out << incl.comment
521
+ out << incl.comment.parse
522
522
  end
523
523
 
524
524
  unless wout.empty? then
@@ -542,7 +542,7 @@ or the PAGER environment variable.
542
542
 
543
543
  if include.comment then
544
544
  out << RDoc::Markup::BlankLine.new
545
- out << include.comment
545
+ out << include.comment.parse
546
546
  end
547
547
  end
548
548
 
@@ -657,12 +657,12 @@ or the PAGER environment variable.
657
657
  ##
658
658
  # Adds the class +comment+ to +out+.
659
659
 
660
- def class_document_comment out, comment # :nodoc:
661
- unless comment.empty? then
660
+ def class_document_comment out, document # :nodoc:
661
+ unless document.empty? then
662
662
  out << RDoc::Markup::Rule.new(1)
663
663
 
664
- if comment.merged? then
665
- parts = comment.parts
664
+ if document.merged? then
665
+ parts = document.parts
666
666
  parts = parts.zip [RDoc::Markup::BlankLine.new] * parts.length
667
667
  parts.flatten!
668
668
  parts.pop
@@ -687,7 +687,7 @@ or the PAGER environment variable.
687
687
  constants = klass.constants.sort_by { |constant| constant.name }
688
688
 
689
689
  list.items.concat constants.map { |constant|
690
- parts = constant.comment.parts if constant.comment
690
+ parts = constant.comment.parse.parts
691
691
  parts << RDoc::Markup::Paragraph.new('[not documented]') if
692
692
  parts.empty?
693
693
 
@@ -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
 
@@ -906,7 +914,7 @@ or the PAGER environment variable.
906
914
 
907
915
  page = store.load_page page_name
908
916
 
909
- display page.comment
917
+ display page.comment.parse
910
918
  end
911
919
 
912
920
  ##
@@ -1207,7 +1215,8 @@ or the PAGER environment variable.
1207
1215
 
1208
1216
  store.load_method klass, "#{type}#{method}"
1209
1217
  rescue RDoc::Store::MissingFileError => e
1210
- comment = RDoc::Comment.new("missing documentation at #{e.file}").parse
1218
+ comment = RDoc::Comment.new("missing documentation at #{e.file}")
1219
+ comment.parse
1211
1220
 
1212
1221
  method = RDoc::AnyMethod.new nil, name
1213
1222
  method.comment = comment
@@ -1367,13 +1376,13 @@ or the PAGER environment variable.
1367
1376
  # documentable items the class is added to +also_in+ instead.
1368
1377
 
1369
1378
  def render_class out, store, klass, also_in # :nodoc:
1370
- comment = klass.comment
1379
+ document = klass.comment.parse
1371
1380
  # TODO the store's cache should always return an empty Array
1372
1381
  class_methods = store.class_methods[klass.full_name] || []
1373
1382
  instance_methods = store.instance_methods[klass.full_name] || []
1374
1383
  attributes = store.attributes[klass.full_name] || []
1375
1384
 
1376
- if comment.empty? and
1385
+ if document.empty? and
1377
1386
  instance_methods.empty? and class_methods.empty? then
1378
1387
  also_in << store
1379
1388
  return
@@ -1381,7 +1390,7 @@ or the PAGER environment variable.
1381
1390
 
1382
1391
  add_from out, store
1383
1392
 
1384
- class_document_comment out, comment
1393
+ class_document_comment out, document
1385
1394
 
1386
1395
  if class_methods or instance_methods or not klass.constants.empty? then
1387
1396
  out << RDoc::Markup::Rule.new(1)
@@ -1429,16 +1438,16 @@ or the PAGER environment variable.
1429
1438
  if alias_for
1430
1439
  unless method.comment.nil? or method.comment.empty?
1431
1440
  out << RDoc::Markup::BlankLine.new
1432
- out << method.comment
1441
+ out << method.comment.parse
1433
1442
  end
1434
1443
  out << RDoc::Markup::BlankLine.new
1435
1444
  out << RDoc::Markup::Paragraph.new("(This method is an alias for #{alias_for.full_name}.)")
1436
1445
  out << RDoc::Markup::BlankLine.new
1437
- out << alias_for.comment
1446
+ out << alias_for.comment.parse
1438
1447
  out << RDoc::Markup::BlankLine.new
1439
1448
  else
1440
1449
  out << RDoc::Markup::BlankLine.new
1441
- out << method.comment
1450
+ out << method.comment.parse
1442
1451
  out << RDoc::Markup::BlankLine.new
1443
1452
  end
1444
1453
  end
@@ -1551,7 +1560,7 @@ or the PAGER environment variable.
1551
1560
  found_pages.each do |page|
1552
1561
  out << RDoc::Markup::Heading.new(4, "Expanded from #{page.full_name}")
1553
1562
  out << RDoc::Markup::BlankLine.new
1554
- out << page.comment
1563
+ out << page.comment.parse
1555
1564
  end
1556
1565
  end
1557
1566
  end
@@ -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.11.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.11.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-01-16 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>