rdoc 6.5.0 → 6.5.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acfa378032b35ef7563cf5255d5d3127b1fa8066dd5c5255088d7d13fdabb757
4
- data.tar.gz: 0bbc31e7348fcc5227a9b4319dc48cfb5e40143eeaeeb471921a5b2c6b098220
3
+ metadata.gz: 847213367e1e1b418f9b04f706e922fb9819940e738100334aa65307512aaa85
4
+ data.tar.gz: 04e77e04cf5dff2f3a3a9e3513e3d09613c954ac1c3a07b69c89bf63a829c23d
5
5
  SHA512:
6
- metadata.gz: 7ad2f4cdcf3e7ffa7f81bc8d5795b1481d9c8f7feeba0f2a6455555cecbee603c5fb24e4e612929a7ff314ff027f69b561a0d8cf343c4099ea554db216ad3078
7
- data.tar.gz: 93bf81edf3cd84b35db94038b5978abd548042919a1dd3cd039431a681736a3aafe098135c86abe0701dbf3f242bae8af64b293d2f908b2a258ce5075f1519b3
6
+ metadata.gz: dc0c88c8c59219ed05af3141947b92f32f7123062d77b644d20f9ef5c63ccffbad5a22e705b06f31d9307006a81dfe01d4a1dc483e26894b93c7d9a07e88ae32
7
+ data.tar.gz: 79d8c258e8e750bcf574288e572a68d8429efa1fa4460928685055aace0bf2010d5da30163cc9d6e40a99d19f305d7c5c4b69a4a7dd5100387cef3ca95ecbbe8
@@ -39,45 +39,75 @@ class RDoc::Markdown::Literals
39
39
  attr_accessor :result, :pos
40
40
 
41
41
  def current_column(target=pos)
42
- if c = string.rindex("\n", target-1)
43
- 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
44
46
  end
45
47
 
46
48
  target + 1
47
49
  end
48
50
 
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
62
+
49
63
  if [].respond_to? :bsearch_index
50
64
  def current_line(target=pos)
51
- unless @line_offsets
52
- @line_offsets = []
53
- total = 0
54
- string.each_line do |line|
55
- total += line.size
56
- @line_offsets << total
57
- end
65
+ if line = position_line_offsets.bsearch_index {|x| x > target }
66
+ return line + 1
58
67
  end
59
-
60
- @line_offsets.bsearch_index {|x| x >= target } + 1 || -1
68
+ raise "Target position #{target} is outside of string"
61
69
  end
62
70
  else
63
71
  def current_line(target=pos)
64
- cur_offset = 0
65
- cur_line = 0
66
-
67
- string.each_line do |line|
68
- cur_line += 1
69
- cur_offset += line.size
70
- return cur_line if cur_offset >= target
72
+ if line = position_line_offsets.index {|x| x > target }
73
+ return line + 1
71
74
  end
72
75
 
73
- -1
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"
74
83
  end
84
+ string[target, 1]
85
+ end
86
+
87
+ KpegPosInfo = Struct.new(:pos, :lno, :col, :line, :char)
88
+
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)
75
95
  end
76
96
 
77
97
  def lines
78
- lines = []
79
- string.each_line { |l| lines << l }
80
- 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]
81
111
  end
82
112
 
83
113
 
@@ -91,6 +121,7 @@ class RDoc::Markdown::Literals
91
121
  @string = string
92
122
  @string_size = string ? string.size : 0
93
123
  @pos = pos
124
+ @position_line_offsets = nil
94
125
  end
95
126
 
96
127
  def show_pos
@@ -115,30 +146,22 @@ class RDoc::Markdown::Literals
115
146
  end
116
147
 
117
148
  def failure_caret
118
- l = current_line @failing_rule_offset
119
- c = current_column @failing_rule_offset
120
-
121
- line = lines[l-1]
122
- "#{line}\n#{' ' * (c - 1)}^"
149
+ p = current_pos_info @failing_rule_offset
150
+ "#{p.line.chomp}\n#{' ' * (p.col - 1)}^"
123
151
  end
124
152
 
125
153
  def failure_character
126
- l = current_line @failing_rule_offset
127
- c = current_column @failing_rule_offset
128
- lines[l-1][c-1, 1]
154
+ current_character @failing_rule_offset
129
155
  end
130
156
 
131
157
  def failure_oneline
132
- l = current_line @failing_rule_offset
133
- c = current_column @failing_rule_offset
134
-
135
- char = lines[l-1][c-1, 1]
158
+ p = current_pos_info @failing_rule_offset
136
159
 
137
160
  if @failed_rule.kind_of? Symbol
138
161
  info = self.class::Rules[@failed_rule]
139
- "@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
162
+ "@#{p.lno}:#{p.col} failed rule '#{info.name}', got '#{p.char}'"
140
163
  else
141
- "@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
164
+ "@#{p.lno}:#{p.col} failed rule '#{@failed_rule}', got '#{p.char}'"
142
165
  end
143
166
  end
144
167
 
@@ -151,10 +174,9 @@ class RDoc::Markdown::Literals
151
174
 
152
175
  def show_error(io=STDOUT)
153
176
  error_pos = @failing_rule_offset
154
- line_no = current_line(error_pos)
155
- col_no = current_column(error_pos)
177
+ p = current_pos_info(error_pos)
156
178
 
157
- io.puts "On line #{line_no}, column #{col_no}:"
179
+ io.puts "On line #{p.lno}, column #{p.col}:"
158
180
 
159
181
  if @failed_rule.kind_of? Symbol
160
182
  info = self.class::Rules[@failed_rule]
@@ -163,10 +185,9 @@ class RDoc::Markdown::Literals
163
185
  io.puts "Failed to match rule '#{@failed_rule}'"
164
186
  end
165
187
 
166
- io.puts "Got: #{string[error_pos,1].inspect}"
167
- line = lines[line_no-1]
168
- io.puts "=> #{line}"
169
- io.print(" " * (col_no + 3))
188
+ io.puts "Got: #{p.char.inspect}"
189
+ io.puts "=> #{p.line}"
190
+ io.print(" " * (p.col + 2))
170
191
  io.puts "^"
171
192
  end
172
193
 
@@ -275,6 +296,7 @@ class RDoc::Markdown::Literals
275
296
  end
276
297
 
277
298
  def apply_with_args(rule, *args)
299
+ @result = nil
278
300
  memo_key = [rule, args]
279
301
  if m = @memoizations[memo_key][@pos]
280
302
  @pos = m.pos
@@ -308,6 +330,7 @@ class RDoc::Markdown::Literals
308
330
  end
309
331
 
310
332
  def apply(rule)
333
+ @result = nil
311
334
  if m = @memoizations[rule][@pos]
312
335
  @pos = m.pos
313
336
  if !m.set
data/lib/rdoc/markdown.rb CHANGED
@@ -466,6 +466,7 @@ class RDoc::Markdown
466
466
  end
467
467
 
468
468
  def apply_with_args(rule, *args)
469
+ @result = nil
469
470
  memo_key = [rule, args]
470
471
  if m = @memoizations[memo_key][@pos]
471
472
  @pos = m.pos
@@ -499,6 +500,7 @@ class RDoc::Markdown
499
500
  end
500
501
 
501
502
  def apply(rule)
503
+ @result = nil
502
504
  if m = @memoizations[rule][@pos]
503
505
  @pos = m.pos
504
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.6.0
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'
@@ -624,6 +624,7 @@ Racc_arg = [
624
624
  racc_shift_n,
625
625
  racc_reduce_n,
626
626
  racc_use_result_var ]
627
+ Ractor.make_shareable(Racc_arg) if defined?(Ractor)
627
628
 
628
629
  Racc_token_to_s_table = [
629
630
  "$end",
@@ -674,6 +675,7 @@ Racc_token_to_s_table = [
674
675
  "blocks_in_list",
675
676
  "block_in_list",
676
677
  "whitelines2" ]
678
+ Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
677
679
 
678
680
  Racc_debug_parser = false
679
681
 
@@ -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.6.0
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/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
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
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
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
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
@@ -5,6 +5,6 @@ module RDoc
5
5
  ##
6
6
  # RDoc version you are using
7
7
 
8
- VERSION = '6.5.0'
8
+ VERSION = '6.5.1.1'
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.5.0
4
+ version: 6.5.1.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: 2022-12-05 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: psych
@@ -250,7 +249,6 @@ homepage: https://ruby.github.io/rdoc
250
249
  licenses:
251
250
  - Ruby
252
251
  metadata: {}
253
- post_install_message:
254
252
  rdoc_options:
255
253
  - "--main"
256
254
  - README.rdoc
@@ -267,8 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
265
  - !ruby/object:Gem::Version
268
266
  version: '2.2'
269
267
  requirements: []
270
- rubygems_version: 3.4.0.dev
271
- signing_key:
268
+ rubygems_version: 3.6.0.dev
272
269
  specification_version: 4
273
270
  summary: RDoc produces HTML and command-line documentation for Ruby projects
274
271
  test_files: []