rdoc 6.3.3 → 6.3.4.1

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: 120ff1fdb58f0543a2a49d1e4fffc2ebaf3f1bcd9f3cd2006f4130b6a4caa330
4
- data.tar.gz: 7c8dabbb3b1256e4bca4b2a14dfb216d43f9bb3acb26d5277b7acbbf6212f5eb
3
+ metadata.gz: 8157b06663b2d3c12fb145a457799e06b5e1bf7955a6f0e76746595d55208040
4
+ data.tar.gz: 7c0ed69cd59714ffbc48003d65534c3be6f8f9052ad519c806e79322bbf11dc0
5
5
  SHA512:
6
- metadata.gz: 38fa507c6bf06b2697642b7a133fcb42ed256aa7b788c7ca6eaba7545d92e071325e2b175020716fca082864efff9e2702aa05f5e5b758e06aa3c3947c972449
7
- data.tar.gz: 655ceb71a41d8e17202c9ecab7dd41af87f30fd16a5be757778f3671563f8779f82982b223b68610c9a7e37899e5311a9614fbbb7df8f80c9533358a4db480cf
6
+ metadata.gz: f7e72019c46c049b0821768bb0411814aa9e0149c2380da1b9da79500d1326c138d15635b51f4d0e9aeafc357ba3fd2e4587e0ab7367645e47e7a05b7bfa79ec
7
+ data.tar.gz: 847a2a553d7cd92628950f91ab758d32ccd7d1781cbf6102a22c06c6ca230e65a64d1cf82414fe92b93efe104e31362454d341a6b574637ca1aa6fd4c9bb0245
data/Rakefile CHANGED
@@ -97,5 +97,5 @@ else
97
97
  RuboCop::RakeTask.new(:rubocop) do |t|
98
98
  t.options = [*parsed_files]
99
99
  end
100
- task :build => [:generate, "rubocop:auto_correct"]
100
+ task :build => [:generate]#, "rubocop:auto_correct"]
101
101
  end
@@ -29,6 +29,7 @@ class RDoc::Markdown::Literals
29
29
  @result = nil
30
30
  @failed_rule = nil
31
31
  @failing_rule_offset = -1
32
+ @line_offsets = nil
32
33
 
33
34
  setup_foreign_grammar
34
35
  end
@@ -38,30 +39,75 @@ class RDoc::Markdown::Literals
38
39
  attr_accessor :result, :pos
39
40
 
40
41
  def current_column(target=pos)
41
- if c = string.rindex("\n", target-1)
42
- return target - c - 1
42
+ if string[target] == "\n" && (c = string.rindex("\n", target-1) || -1)
43
+ return target - c
44
+ elsif c = string.rindex("\n", target)
45
+ return target - c
43
46
  end
44
47
 
45
48
  target + 1
46
49
  end
47
50
 
48
- def current_line(target=pos)
49
- cur_offset = 0
50
- cur_line = 0
51
+ def position_line_offsets
52
+ unless @position_line_offsets
53
+ @position_line_offsets = []
54
+ total = 0
55
+ string.each_line do |line|
56
+ total += line.size
57
+ @position_line_offsets << total
58
+ end
59
+ end
60
+ @position_line_offsets
61
+ end
51
62
 
52
- string.each_line do |line|
53
- cur_line += 1
54
- cur_offset += line.size
55
- return cur_line if cur_offset >= target
63
+ if [].respond_to? :bsearch_index
64
+ def current_line(target=pos)
65
+ if line = position_line_offsets.bsearch_index {|x| x > target }
66
+ return line + 1
67
+ end
68
+ raise "Target position #{target} is outside of string"
56
69
  end
70
+ else
71
+ def current_line(target=pos)
72
+ if line = position_line_offsets.index {|x| x > target }
73
+ return line + 1
74
+ end
75
+
76
+ raise "Target position #{target} is outside of string"
77
+ end
78
+ end
79
+
80
+ def current_character(target=pos)
81
+ if target < 0 || target >= string.size
82
+ raise "Target position #{target} is outside of string"
83
+ end
84
+ string[target, 1]
85
+ end
86
+
87
+ KpegPosInfo = Struct.new(:pos, :lno, :col, :line, :char)
57
88
 
58
- -1
89
+ def current_pos_info(target=pos)
90
+ l = current_line target
91
+ c = current_column target
92
+ ln = get_line(l-1)
93
+ chr = string[target,1]
94
+ KpegPosInfo.new(target, l, c, ln, chr)
59
95
  end
60
96
 
61
97
  def lines
62
- lines = []
63
- string.each_line { |l| lines << l }
64
- lines
98
+ string.lines
99
+ end
100
+
101
+ def get_line(no)
102
+ loff = position_line_offsets
103
+ if no < 0
104
+ raise "Line No is out of range: #{no} < 0"
105
+ elsif no >= loff.size
106
+ raise "Line No is out of range: #{no} >= #{loff.size}"
107
+ end
108
+ lend = loff[no]-1
109
+ lstart = no > 0 ? loff[no-1] : 0
110
+ string[lstart..lend]
65
111
  end
66
112
 
67
113
 
@@ -75,6 +121,7 @@ class RDoc::Markdown::Literals
75
121
  @string = string
76
122
  @string_size = string ? string.size : 0
77
123
  @pos = pos
124
+ @position_line_offsets = nil
78
125
  end
79
126
 
80
127
  def show_pos
@@ -99,30 +146,22 @@ class RDoc::Markdown::Literals
99
146
  end
100
147
 
101
148
  def failure_caret
102
- l = current_line @failing_rule_offset
103
- c = current_column @failing_rule_offset
104
-
105
- line = lines[l-1]
106
- "#{line}\n#{' ' * (c - 1)}^"
149
+ p = current_pos_info @failing_rule_offset
150
+ "#{p.line.chomp}\n#{' ' * (p.col - 1)}^"
107
151
  end
108
152
 
109
153
  def failure_character
110
- l = current_line @failing_rule_offset
111
- c = current_column @failing_rule_offset
112
- lines[l-1][c-1, 1]
154
+ current_character @failing_rule_offset
113
155
  end
114
156
 
115
157
  def failure_oneline
116
- l = current_line @failing_rule_offset
117
- c = current_column @failing_rule_offset
118
-
119
- char = lines[l-1][c-1, 1]
158
+ p = current_pos_info @failing_rule_offset
120
159
 
121
160
  if @failed_rule.kind_of? Symbol
122
161
  info = self.class::Rules[@failed_rule]
123
- "@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
162
+ "@#{p.lno}:#{p.col} failed rule '#{info.name}', got '#{p.char}'"
124
163
  else
125
- "@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
164
+ "@#{p.lno}:#{p.col} failed rule '#{@failed_rule}', got '#{p.char}'"
126
165
  end
127
166
  end
128
167
 
@@ -135,10 +174,9 @@ class RDoc::Markdown::Literals
135
174
 
136
175
  def show_error(io=STDOUT)
137
176
  error_pos = @failing_rule_offset
138
- line_no = current_line(error_pos)
139
- col_no = current_column(error_pos)
177
+ p = current_pos_info(error_pos)
140
178
 
141
- io.puts "On line #{line_no}, column #{col_no}:"
179
+ io.puts "On line #{p.lno}, column #{p.col}:"
142
180
 
143
181
  if @failed_rule.kind_of? Symbol
144
182
  info = self.class::Rules[@failed_rule]
@@ -147,10 +185,9 @@ class RDoc::Markdown::Literals
147
185
  io.puts "Failed to match rule '#{@failed_rule}'"
148
186
  end
149
187
 
150
- io.puts "Got: #{string[error_pos,1].inspect}"
151
- line = lines[line_no-1]
152
- io.puts "=> #{line}"
153
- io.print(" " * (col_no + 3))
188
+ io.puts "Got: #{p.char.inspect}"
189
+ io.puts "=> #{p.line}"
190
+ io.print(" " * (p.col + 2))
154
191
  io.puts "^"
155
192
  end
156
193
 
@@ -259,6 +296,7 @@ class RDoc::Markdown::Literals
259
296
  end
260
297
 
261
298
  def apply_with_args(rule, *args)
299
+ @result = nil
262
300
  memo_key = [rule, args]
263
301
  if m = @memoizations[memo_key][@pos]
264
302
  @pos = m.pos
@@ -292,6 +330,7 @@ class RDoc::Markdown::Literals
292
330
  end
293
331
 
294
332
  def apply(rule)
333
+ @result = nil
295
334
  if m = @memoizations[rule][@pos]
296
335
  @pos = m.pos
297
336
  if !m.set
data/lib/rdoc/markdown.rb CHANGED
@@ -199,6 +199,7 @@ class RDoc::Markdown
199
199
  @result = nil
200
200
  @failed_rule = nil
201
201
  @failing_rule_offset = -1
202
+ @line_offsets = nil
202
203
 
203
204
  setup_foreign_grammar
204
205
  end
@@ -208,30 +209,75 @@ class RDoc::Markdown
208
209
  attr_accessor :result, :pos
209
210
 
210
211
  def current_column(target=pos)
211
- if c = string.rindex("\n", target-1)
212
- return target - c - 1
212
+ if string[target] == "\n" && (c = string.rindex("\n", target-1) || -1)
213
+ return target - c
214
+ elsif c = string.rindex("\n", target)
215
+ return target - c
213
216
  end
214
217
 
215
218
  target + 1
216
219
  end
217
220
 
218
- def current_line(target=pos)
219
- cur_offset = 0
220
- cur_line = 0
221
+ def position_line_offsets
222
+ unless @position_line_offsets
223
+ @position_line_offsets = []
224
+ total = 0
225
+ string.each_line do |line|
226
+ total += line.size
227
+ @position_line_offsets << total
228
+ end
229
+ end
230
+ @position_line_offsets
231
+ end
221
232
 
222
- string.each_line do |line|
223
- cur_line += 1
224
- cur_offset += line.size
225
- return cur_line if cur_offset >= target
233
+ if [].respond_to? :bsearch_index
234
+ def current_line(target=pos)
235
+ if line = position_line_offsets.bsearch_index {|x| x > target }
236
+ return line + 1
237
+ end
238
+ raise "Target position #{target} is outside of string"
226
239
  end
240
+ else
241
+ def current_line(target=pos)
242
+ if line = position_line_offsets.index {|x| x > target }
243
+ return line + 1
244
+ end
245
+
246
+ raise "Target position #{target} is outside of string"
247
+ end
248
+ end
249
+
250
+ def current_character(target=pos)
251
+ if target < 0 || target >= string.size
252
+ raise "Target position #{target} is outside of string"
253
+ end
254
+ string[target, 1]
255
+ end
256
+
257
+ KpegPosInfo = Struct.new(:pos, :lno, :col, :line, :char)
227
258
 
228
- -1
259
+ def current_pos_info(target=pos)
260
+ l = current_line target
261
+ c = current_column target
262
+ ln = get_line(l-1)
263
+ chr = string[target,1]
264
+ KpegPosInfo.new(target, l, c, ln, chr)
229
265
  end
230
266
 
231
267
  def lines
232
- lines = []
233
- string.each_line { |l| lines << l }
234
- lines
268
+ string.lines
269
+ end
270
+
271
+ def get_line(no)
272
+ loff = position_line_offsets
273
+ if no < 0
274
+ raise "Line No is out of range: #{no} < 0"
275
+ elsif no >= loff.size
276
+ raise "Line No is out of range: #{no} >= #{loff.size}"
277
+ end
278
+ lend = loff[no]-1
279
+ lstart = no > 0 ? loff[no-1] : 0
280
+ string[lstart..lend]
235
281
  end
236
282
 
237
283
 
@@ -245,6 +291,7 @@ class RDoc::Markdown
245
291
  @string = string
246
292
  @string_size = string ? string.size : 0
247
293
  @pos = pos
294
+ @position_line_offsets = nil
248
295
  end
249
296
 
250
297
  def show_pos
@@ -269,30 +316,22 @@ class RDoc::Markdown
269
316
  end
270
317
 
271
318
  def failure_caret
272
- l = current_line @failing_rule_offset
273
- c = current_column @failing_rule_offset
274
-
275
- line = lines[l-1]
276
- "#{line}\n#{' ' * (c - 1)}^"
319
+ p = current_pos_info @failing_rule_offset
320
+ "#{p.line.chomp}\n#{' ' * (p.col - 1)}^"
277
321
  end
278
322
 
279
323
  def failure_character
280
- l = current_line @failing_rule_offset
281
- c = current_column @failing_rule_offset
282
- lines[l-1][c-1, 1]
324
+ current_character @failing_rule_offset
283
325
  end
284
326
 
285
327
  def failure_oneline
286
- l = current_line @failing_rule_offset
287
- c = current_column @failing_rule_offset
288
-
289
- char = lines[l-1][c-1, 1]
328
+ p = current_pos_info @failing_rule_offset
290
329
 
291
330
  if @failed_rule.kind_of? Symbol
292
331
  info = self.class::Rules[@failed_rule]
293
- "@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
332
+ "@#{p.lno}:#{p.col} failed rule '#{info.name}', got '#{p.char}'"
294
333
  else
295
- "@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
334
+ "@#{p.lno}:#{p.col} failed rule '#{@failed_rule}', got '#{p.char}'"
296
335
  end
297
336
  end
298
337
 
@@ -305,10 +344,9 @@ class RDoc::Markdown
305
344
 
306
345
  def show_error(io=STDOUT)
307
346
  error_pos = @failing_rule_offset
308
- line_no = current_line(error_pos)
309
- col_no = current_column(error_pos)
347
+ p = current_pos_info(error_pos)
310
348
 
311
- io.puts "On line #{line_no}, column #{col_no}:"
349
+ io.puts "On line #{p.lno}, column #{p.col}:"
312
350
 
313
351
  if @failed_rule.kind_of? Symbol
314
352
  info = self.class::Rules[@failed_rule]
@@ -317,10 +355,9 @@ class RDoc::Markdown
317
355
  io.puts "Failed to match rule '#{@failed_rule}'"
318
356
  end
319
357
 
320
- io.puts "Got: #{string[error_pos,1].inspect}"
321
- line = lines[line_no-1]
322
- io.puts "=> #{line}"
323
- io.print(" " * (col_no + 3))
358
+ io.puts "Got: #{p.char.inspect}"
359
+ io.puts "=> #{p.line}"
360
+ io.print(" " * (p.col + 2))
324
361
  io.puts "^"
325
362
  end
326
363
 
@@ -429,6 +466,7 @@ class RDoc::Markdown
429
466
  end
430
467
 
431
468
  def apply_with_args(rule, *args)
469
+ @result = nil
432
470
  memo_key = [rule, args]
433
471
  if m = @memoizations[memo_key][@pos]
434
472
  @pos = m.pos
@@ -462,6 +500,7 @@ class RDoc::Markdown
462
500
  end
463
501
 
464
502
  def apply(rule)
503
+ @result = nil
465
504
  if m = @memoizations[rule][@pos]
466
505
  @pos = m.pos
467
506
  if !m.set
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
3
  # DO NOT MODIFY!!!!
4
- # This file is automatically generated by Racc 1.5.2
5
- # from Racc grammar file "".
4
+ # This file is automatically generated by Racc 1.7.3
5
+ # from Racc grammar file "block_parser.ry".
6
6
  #
7
7
 
8
8
  require 'racc/parser.rb'
@@ -620,6 +620,7 @@ Racc_arg = [
620
620
  racc_shift_n,
621
621
  racc_reduce_n,
622
622
  racc_use_result_var ]
623
+ Ractor.make_shareable(Racc_arg) if defined?(Ractor)
623
624
 
624
625
  Racc_token_to_s_table = [
625
626
  "$end",
@@ -670,6 +671,7 @@ Racc_token_to_s_table = [
670
671
  "blocks_in_list",
671
672
  "block_in_list",
672
673
  "whitelines2" ]
674
+ Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
673
675
 
674
676
  Racc_debug_parser = false
675
677
 
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
3
  # DO NOT MODIFY!!!!
4
- # This file is automatically generated by Racc 1.5.2
5
- # from Racc grammar file "".
4
+ # This file is automatically generated by Racc 1.7.3
5
+ # from Racc grammar file "inline_parser.ry".
6
6
  #
7
7
 
8
8
  require 'racc/parser.rb'
@@ -652,6 +652,7 @@ Racc_arg = [
652
652
  racc_shift_n,
653
653
  racc_reduce_n,
654
654
  racc_use_result_var ]
655
+ Ractor.make_shareable(Racc_arg) if defined?(Ractor)
655
656
 
656
657
  Racc_token_to_s_table = [
657
658
  "$end",
@@ -723,6 +724,7 @@ Racc_token_to_s_table = [
723
724
  "normal_strings",
724
725
  "verb_string",
725
726
  "verb_normal_string" ]
727
+ Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
726
728
 
727
729
  Racc_debug_parser = false
728
730
 
data/lib/rdoc/rdoc.rb CHANGED
@@ -162,11 +162,12 @@ class RDoc::RDoc
162
162
  RDoc.load_yaml
163
163
 
164
164
  begin
165
- options = YAML.load_file '.rdoc_options'
165
+ options = YAML.safe_load_file '.rdoc_options', permitted_classes: [RDoc::Options, Symbol]
166
166
  rescue Psych::SyntaxError
167
+ raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
167
168
  end
168
169
 
169
- return RDoc::Options.new if options == false # Allow empty file.
170
+ return RDoc::Options.new unless options # Allow empty file.
170
171
 
171
172
  raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
172
173
  RDoc::Options === options or Hash === options
data/lib/rdoc/store.rb CHANGED
@@ -556,9 +556,7 @@ class RDoc::Store
556
556
  def load_cache
557
557
  #orig_enc = @encoding
558
558
 
559
- File.open cache_path, 'rb' do |io|
560
- @cache = Marshal.load io.read
561
- end
559
+ @cache = marshal_load(cache_path)
562
560
 
563
561
  load_enc = @cache[:encoding]
564
562
 
@@ -615,9 +613,7 @@ class RDoc::Store
615
613
  def load_class_data klass_name
616
614
  file = class_file klass_name
617
615
 
618
- File.open file, 'rb' do |io|
619
- Marshal.load io.read
620
- end
616
+ marshal_load(file)
621
617
  rescue Errno::ENOENT => e
622
618
  error = MissingFileError.new(self, file, klass_name)
623
619
  error.set_backtrace e.backtrace
@@ -630,14 +626,10 @@ class RDoc::Store
630
626
  def load_method klass_name, method_name
631
627
  file = method_file klass_name, method_name
632
628
 
633
- File.open file, 'rb' do |io|
634
- obj = Marshal.load io.read
635
- obj.store = self
636
- obj.parent =
637
- find_class_or_module(klass_name) || load_class(klass_name) unless
638
- obj.parent
639
- obj
640
- end
629
+ obj = marshal_load(file)
630
+ obj.store = self
631
+ obj.parent ||= find_class_or_module(klass_name) || load_class(klass_name)
632
+ obj
641
633
  rescue Errno::ENOENT => e
642
634
  error = MissingFileError.new(self, file, klass_name + method_name)
643
635
  error.set_backtrace e.backtrace
@@ -650,11 +642,9 @@ class RDoc::Store
650
642
  def load_page page_name
651
643
  file = page_file page_name
652
644
 
653
- File.open file, 'rb' do |io|
654
- obj = Marshal.load io.read
655
- obj.store = self
656
- obj
657
- end
645
+ obj = marshal_load(file)
646
+ obj.store = self
647
+ obj
658
648
  rescue Errno::ENOENT => e
659
649
  error = MissingFileError.new(self, file, page_name)
660
650
  error.set_backtrace e.backtrace
@@ -976,4 +966,21 @@ class RDoc::Store
976
966
  @unique_modules
977
967
  end
978
968
 
969
+ private
970
+ def marshal_load(file)
971
+ File.open(file, 'rb') {|io| Marshal.load(io, MarshalFilter)}
972
+ end
973
+
974
+ MarshalFilter = proc do |obj|
975
+ case obj
976
+ when true, false, nil, Array, Class, Encoding, Hash, Integer, String, Symbol, RDoc::Text
977
+ else
978
+ unless obj.class.name.start_with?("RDoc::")
979
+ raise TypeError, "not permitted class: #{obj.class.name}"
980
+ end
981
+ end
982
+ obj
983
+ end
984
+ private_constant :MarshalFilter
985
+
979
986
  end
data/lib/rdoc/version.rb CHANGED
@@ -3,6 +3,6 @@ module RDoc
3
3
  ##
4
4
  # RDoc version you are using
5
5
 
6
- VERSION = '6.3.3'
6
+ VERSION = '6.3.4.1'
7
7
 
8
8
  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.3.3
4
+ version: 6.3.4.1
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: 2021-11-11 00:00:00.000000000 Z
16
+ date: 2024-03-21 00:00:00.000000000 Z
18
17
  dependencies:
19
18
  - !ruby/object:Gem::Dependency
20
19
  name: gettext
@@ -255,7 +254,6 @@ homepage: https://ruby.github.io/rdoc
255
254
  licenses:
256
255
  - Ruby
257
256
  metadata: {}
258
- post_install_message:
259
257
  rdoc_options:
260
258
  - "--main"
261
259
  - README.rdoc
@@ -272,8 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
270
  - !ruby/object:Gem::Version
273
271
  version: '2.2'
274
272
  requirements: []
275
- rubygems_version: 3.3.0.dev
276
- signing_key:
273
+ rubygems_version: 3.6.0.dev
277
274
  specification_version: 4
278
275
  summary: RDoc produces HTML and command-line documentation for Ruby projects
279
276
  test_files: []