rdoc 6.3.4.1 → 6.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8157b06663b2d3c12fb145a457799e06b5e1bf7955a6f0e76746595d55208040
4
- data.tar.gz: 7c0ed69cd59714ffbc48003d65534c3be6f8f9052ad519c806e79322bbf11dc0
3
+ metadata.gz: d6c9787594ed9d69a7a9177e449d925063acbc6ace0273f7d0b1fc9ca6a31139
4
+ data.tar.gz: 5f5afd10a18a1aeabc8319350c191eeaa137e5f715a2e95cbf2443f5dca7f96c
5
5
  SHA512:
6
- metadata.gz: f7e72019c46c049b0821768bb0411814aa9e0149c2380da1b9da79500d1326c138d15635b51f4d0e9aeafc357ba3fd2e4587e0ab7367645e47e7a05b7bfa79ec
7
- data.tar.gz: 847a2a553d7cd92628950f91ab758d32ccd7d1781cbf6102a22c06c6ca230e65a64d1cf82414fe92b93efe104e31362454d341a6b574637ca1aa6fd4c9bb0245
6
+ metadata.gz: 94fbc007d81c0cc1774b44d5f174b5e011ef5ae3d998344b981a8b6170f1c630c3c80e45f87bcc4c05f97f51e34e9f3ede791846e0c01e4015c45cc8aab1b05e
7
+ data.tar.gz: '068da922a56b61ca85fa7b61d5554cdbe1533c30caae11e7d81894e41fca58157971c18a76c55391538324c168a720c2cbbc8150a12dc276eab033e70fae0217'
data/Gemfile CHANGED
@@ -3,10 +3,10 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- gem "rake"
7
- gem "racc", "> 1.4.10"
8
- gem "kpeg"
9
- gem "test-unit"
10
- gem "minitest" # for test_rdoc_rubygems_hook.rb
11
- gem "rubocop"
6
+ gem 'rake'
7
+ gem 'racc', '> 1.4.10'
8
+ gem 'kpeg', github: 'evanphx/kpeg'
9
+ gem 'test-unit'
10
+ gem 'rubocop'
11
+ gem 'gettext'
12
12
  end
data/Rakefile CHANGED
@@ -90,6 +90,12 @@ task "#{path}.gem" => package_parser_files
90
90
  desc "Generate all files used racc and kpeg"
91
91
  task :generate => parsed_files
92
92
 
93
+ task :clean do
94
+ parsed_files.each do |path|
95
+ File.delete(path) if File.exist?(path)
96
+ end
97
+ end
98
+
93
99
  begin
94
100
  require 'rubocop/rake_task'
95
101
  rescue LoadError
@@ -97,5 +103,5 @@ else
97
103
  RuboCop::RakeTask.new(:rubocop) do |t|
98
104
  t.options = [*parsed_files]
99
105
  end
100
- task :build => [:generate]#, "rubocop:auto_correct"]
106
+ task :build => [:generate, "rubocop:auto_correct"]
101
107
  end
@@ -26,6 +26,9 @@ class RDoc::AnyMethod < RDoc::MethodAttr
26
26
 
27
27
  attr_accessor :c_function
28
28
 
29
+ # The section title of the method (if defined in a C file via +:category:+)
30
+ attr_accessor :section_title
31
+
29
32
  # Parameters for this method
30
33
 
31
34
  attr_accessor :params
@@ -356,6 +359,6 @@ class RDoc::AnyMethod < RDoc::MethodAttr
356
359
  entry =~ /\s#{ignore}\s/
357
360
  end
358
361
 
359
- matching.join "\n"
362
+ matching.empty? ? nil : matching.join("\n")
360
363
  end
361
364
  end
@@ -19,7 +19,7 @@ class RDoc::CrossReference
19
19
  #
20
20
  # See CLASS_REGEXP_STR
21
21
 
22
- METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>|\+@|-@|-|\+|\*)(?:\([\w.+*/=<>-]*\))?'
22
+ METHOD_REGEXP_STR = '([A-Za-z]\w*[!?=]?|%|===?|\[\]=?|<<|>>|\+@|-@|-|\+|\*)(?:\([\w.+*/=<>-]*\))?'
23
23
 
24
24
  ##
25
25
  # Regular expressions matching text that should potentially have
@@ -34,12 +34,6 @@ class RDoc::CrossReference
34
34
  # A::B::C.meth
35
35
  #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
36
36
 
37
- # Stand-alone method (preceded by a #)
38
- | \\?\##{METHOD_REGEXP_STR}
39
-
40
- # Stand-alone method (preceded by ::)
41
- | ::#{METHOD_REGEXP_STR}
42
-
43
37
  # A::B::C
44
38
  # The stuff after CLASS_REGEXP_STR is a
45
39
  # nasty hack. CLASS_REGEXP_STR unfortunately matches
@@ -56,6 +50,12 @@ class RDoc::CrossReference
56
50
  # marker.
57
51
  | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
58
52
 
53
+ # Stand-alone method (preceded by a #)
54
+ | \\?\##{METHOD_REGEXP_STR}
55
+
56
+ # Stand-alone method (preceded by ::)
57
+ | ::#{METHOD_REGEXP_STR}
58
+
59
59
  # Things that look like filenames
60
60
  # The key thing is that there must be at least
61
61
  # one special character (period, slash, or
@@ -82,12 +82,12 @@ class RDoc::CrossReference
82
82
  # A::B::C.meth
83
83
  #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
84
84
 
85
- # Stand-alone method
86
- | \\?#{METHOD_REGEXP_STR}
87
-
88
85
  # A::B::C
89
86
  | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
90
87
 
88
+ # Stand-alone method
89
+ | \\?#{METHOD_REGEXP_STR}
90
+
91
91
  # Things that look like filenames
92
92
  | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+
93
93
 
@@ -115,15 +115,8 @@ class RDoc::CrossReference
115
115
  @seen = {}
116
116
  end
117
117
 
118
- ##
119
- # Returns a reference to +name+.
120
- #
121
- # If the reference is found and +name+ is not documented +text+ will be
122
- # returned. If +name+ is escaped +name+ is returned. If +name+ is not
123
- # found +text+ is returned.
124
-
125
- def resolve name, text
126
- return @seen[name] if @seen.include? name
118
+ def resolve_method name
119
+ ref = nil
127
120
 
128
121
  if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
129
122
  type = $2
@@ -165,12 +158,27 @@ class RDoc::CrossReference
165
158
  end
166
159
  end
167
160
 
161
+ ref
162
+ end
163
+
164
+ ##
165
+ # Returns a reference to +name+.
166
+ #
167
+ # If the reference is found and +name+ is not documented +text+ will be
168
+ # returned. If +name+ is escaped +name+ is returned. If +name+ is not
169
+ # found +text+ is returned.
170
+
171
+ def resolve name, text
172
+ return @seen[name] if @seen.include? name
173
+
168
174
  ref = case name
169
175
  when /^\\(#{CLASS_REGEXP_STR})$/o then
170
176
  @context.find_symbol $1
171
177
  else
172
178
  @context.find_symbol name
173
- end unless ref
179
+ end
180
+
181
+ ref = resolve_method name unless ref
174
182
 
175
183
  # Try a page name
176
184
  ref = @store.page name if not ref and name =~ /^[\w.]+$/
@@ -220,8 +220,8 @@ class RDoc::Generator::Darkfish
220
220
  install_rdoc_static_file @template_dir + item, "./#{item}", options
221
221
  end
222
222
 
223
- @options.template_stylesheets.each do |stylesheet|
224
- FileUtils.cp stylesheet, '.', options
223
+ unless @options.template_stylesheets.empty?
224
+ FileUtils.cp @options.template_stylesheets, '.', **options
225
225
  end
226
226
 
227
227
  Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path|
@@ -15,8 +15,6 @@
15
15
 
16
16
  <link href="<%= asset_rel_prefix %>/css/fonts.css" rel="stylesheet">
17
17
  <link href="<%= asset_rel_prefix %>/css/rdoc.css" rel="stylesheet">
18
- <%- if @options.template_stylesheets.flatten.any? then -%>
19
- <%- @options.template_stylesheets.flatten.each do |stylesheet| -%>
18
+ <%- @options.template_stylesheets.each do |stylesheet| -%>
20
19
  <link href="<%= asset_rel_prefix %>/<%= File.basename stylesheet %>" rel="stylesheet">
21
- <%- end -%>
22
20
  <%- end -%>
@@ -29,7 +29,6 @@ class RDoc::Markdown::Literals
29
29
  @result = nil
30
30
  @failed_rule = nil
31
31
  @failing_rule_offset = -1
32
- @line_offsets = nil
33
32
 
34
33
  setup_foreign_grammar
35
34
  end
@@ -39,75 +38,30 @@ class RDoc::Markdown::Literals
39
38
  attr_accessor :result, :pos
40
39
 
41
40
  def current_column(target=pos)
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
41
+ if c = string.rindex("\n", target-1)
42
+ return target - c - 1
46
43
  end
47
44
 
48
45
  target + 1
49
46
  end
50
47
 
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
48
+ def current_line(target=pos)
49
+ cur_offset = 0
50
+ cur_line = 0
62
51
 
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"
52
+ string.each_line do |line|
53
+ cur_line += 1
54
+ cur_offset += line.size
55
+ return cur_line if cur_offset >= target
69
56
  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)
88
57
 
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)
58
+ -1
95
59
  end
96
60
 
97
61
  def 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]
62
+ lines = []
63
+ string.each_line { |l| lines << l }
64
+ lines
111
65
  end
112
66
 
113
67
 
@@ -121,7 +75,6 @@ class RDoc::Markdown::Literals
121
75
  @string = string
122
76
  @string_size = string ? string.size : 0
123
77
  @pos = pos
124
- @position_line_offsets = nil
125
78
  end
126
79
 
127
80
  def show_pos
@@ -146,22 +99,30 @@ class RDoc::Markdown::Literals
146
99
  end
147
100
 
148
101
  def failure_caret
149
- p = current_pos_info @failing_rule_offset
150
- "#{p.line.chomp}\n#{' ' * (p.col - 1)}^"
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)}^"
151
107
  end
152
108
 
153
109
  def failure_character
154
- current_character @failing_rule_offset
110
+ l = current_line @failing_rule_offset
111
+ c = current_column @failing_rule_offset
112
+ lines[l-1][c-1, 1]
155
113
  end
156
114
 
157
115
  def failure_oneline
158
- p = current_pos_info @failing_rule_offset
116
+ l = current_line @failing_rule_offset
117
+ c = current_column @failing_rule_offset
118
+
119
+ char = lines[l-1][c-1, 1]
159
120
 
160
121
  if @failed_rule.kind_of? Symbol
161
122
  info = self.class::Rules[@failed_rule]
162
- "@#{p.lno}:#{p.col} failed rule '#{info.name}', got '#{p.char}'"
123
+ "@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
163
124
  else
164
- "@#{p.lno}:#{p.col} failed rule '#{@failed_rule}', got '#{p.char}'"
125
+ "@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
165
126
  end
166
127
  end
167
128
 
@@ -174,9 +135,10 @@ class RDoc::Markdown::Literals
174
135
 
175
136
  def show_error(io=STDOUT)
176
137
  error_pos = @failing_rule_offset
177
- p = current_pos_info(error_pos)
138
+ line_no = current_line(error_pos)
139
+ col_no = current_column(error_pos)
178
140
 
179
- io.puts "On line #{p.lno}, column #{p.col}:"
141
+ io.puts "On line #{line_no}, column #{col_no}:"
180
142
 
181
143
  if @failed_rule.kind_of? Symbol
182
144
  info = self.class::Rules[@failed_rule]
@@ -185,9 +147,10 @@ class RDoc::Markdown::Literals
185
147
  io.puts "Failed to match rule '#{@failed_rule}'"
186
148
  end
187
149
 
188
- io.puts "Got: #{p.char.inspect}"
189
- io.puts "=> #{p.line}"
190
- io.print(" " * (p.col + 2))
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))
191
154
  io.puts "^"
192
155
  end
193
156
 
@@ -296,7 +259,6 @@ class RDoc::Markdown::Literals
296
259
  end
297
260
 
298
261
  def apply_with_args(rule, *args)
299
- @result = nil
300
262
  memo_key = [rule, args]
301
263
  if m = @memoizations[memo_key][@pos]
302
264
  @pos = m.pos
@@ -330,7 +292,6 @@ class RDoc::Markdown::Literals
330
292
  end
331
293
 
332
294
  def apply(rule)
333
- @result = nil
334
295
  if m = @memoizations[rule][@pos]
335
296
  @pos = m.pos
336
297
  if !m.set
data/lib/rdoc/markdown.rb CHANGED
@@ -199,7 +199,6 @@ class RDoc::Markdown
199
199
  @result = nil
200
200
  @failed_rule = nil
201
201
  @failing_rule_offset = -1
202
- @line_offsets = nil
203
202
 
204
203
  setup_foreign_grammar
205
204
  end
@@ -209,75 +208,30 @@ class RDoc::Markdown
209
208
  attr_accessor :result, :pos
210
209
 
211
210
  def current_column(target=pos)
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
211
+ if c = string.rindex("\n", target-1)
212
+ return target - c - 1
216
213
  end
217
214
 
218
215
  target + 1
219
216
  end
220
217
 
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
218
+ def current_line(target=pos)
219
+ cur_offset = 0
220
+ cur_line = 0
232
221
 
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"
222
+ string.each_line do |line|
223
+ cur_line += 1
224
+ cur_offset += line.size
225
+ return cur_line if cur_offset >= target
239
226
  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)
258
227
 
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)
228
+ -1
265
229
  end
266
230
 
267
231
  def 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]
232
+ lines = []
233
+ string.each_line { |l| lines << l }
234
+ lines
281
235
  end
282
236
 
283
237
 
@@ -291,7 +245,6 @@ class RDoc::Markdown
291
245
  @string = string
292
246
  @string_size = string ? string.size : 0
293
247
  @pos = pos
294
- @position_line_offsets = nil
295
248
  end
296
249
 
297
250
  def show_pos
@@ -316,22 +269,30 @@ class RDoc::Markdown
316
269
  end
317
270
 
318
271
  def failure_caret
319
- p = current_pos_info @failing_rule_offset
320
- "#{p.line.chomp}\n#{' ' * (p.col - 1)}^"
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)}^"
321
277
  end
322
278
 
323
279
  def failure_character
324
- current_character @failing_rule_offset
280
+ l = current_line @failing_rule_offset
281
+ c = current_column @failing_rule_offset
282
+ lines[l-1][c-1, 1]
325
283
  end
326
284
 
327
285
  def failure_oneline
328
- p = current_pos_info @failing_rule_offset
286
+ l = current_line @failing_rule_offset
287
+ c = current_column @failing_rule_offset
288
+
289
+ char = lines[l-1][c-1, 1]
329
290
 
330
291
  if @failed_rule.kind_of? Symbol
331
292
  info = self.class::Rules[@failed_rule]
332
- "@#{p.lno}:#{p.col} failed rule '#{info.name}', got '#{p.char}'"
293
+ "@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
333
294
  else
334
- "@#{p.lno}:#{p.col} failed rule '#{@failed_rule}', got '#{p.char}'"
295
+ "@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
335
296
  end
336
297
  end
337
298
 
@@ -344,9 +305,10 @@ class RDoc::Markdown
344
305
 
345
306
  def show_error(io=STDOUT)
346
307
  error_pos = @failing_rule_offset
347
- p = current_pos_info(error_pos)
308
+ line_no = current_line(error_pos)
309
+ col_no = current_column(error_pos)
348
310
 
349
- io.puts "On line #{p.lno}, column #{p.col}:"
311
+ io.puts "On line #{line_no}, column #{col_no}:"
350
312
 
351
313
  if @failed_rule.kind_of? Symbol
352
314
  info = self.class::Rules[@failed_rule]
@@ -355,9 +317,10 @@ class RDoc::Markdown
355
317
  io.puts "Failed to match rule '#{@failed_rule}'"
356
318
  end
357
319
 
358
- io.puts "Got: #{p.char.inspect}"
359
- io.puts "=> #{p.line}"
360
- io.print(" " * (p.col + 2))
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))
361
324
  io.puts "^"
362
325
  end
363
326
 
@@ -466,7 +429,6 @@ class RDoc::Markdown
466
429
  end
467
430
 
468
431
  def apply_with_args(rule, *args)
469
- @result = nil
470
432
  memo_key = [rule, args]
471
433
  if m = @memoizations[memo_key][@pos]
472
434
  @pos = m.pos
@@ -500,7 +462,6 @@ class RDoc::Markdown
500
462
  end
501
463
 
502
464
  def apply(rule)
503
- @result = nil
504
465
  if m = @memoizations[rule][@pos]
505
466
  @pos = m.pos
506
467
  if !m.set
@@ -163,6 +163,8 @@ class RDoc::Markup::PreProcess
163
163
  if RDoc::Context === code_object then
164
164
  section = code_object.add_section param
165
165
  code_object.temporary_section = section
166
+ elsif RDoc::AnyMethod === code_object then
167
+ code_object.section_title = param
166
168
  end
167
169
 
168
170
  blankline # ignore category if we're not on an RDoc::Context
@@ -357,8 +357,8 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
357
357
  url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
358
358
  "<img src=\"#{url}\" />"
359
359
  else
360
- if scheme != 'link' and /\.(?:rb|rdoc|md)\z/i =~ url
361
- url = url.sub(%r%\A([./]*)(.*)\z%) { "#$1#{$2.tr('.', '_')}.html" }
360
+ if scheme != 'link' and %r%\A((?!https?:)(?:[^/#]*/)*+)([^/#]+)\.(rb|rdoc|md)(?=\z|#)%i =~ url
361
+ url = "#$1#{$2.tr('.', '_')}_#$3.html#$'"
362
362
  end
363
363
 
364
364
  text = text.sub %r%^#{scheme}:/*%i, ''
data/lib/rdoc/options.rb CHANGED
@@ -971,7 +971,7 @@ Usage: #{opt.program_name} [options] [names...]
971
971
  opt.on("--template-stylesheets=FILES", PathArray,
972
972
  "Set (or add to) the list of files to",
973
973
  "include with the html template.") do |value|
974
- @template_stylesheets << value
974
+ @template_stylesheets.concat value
975
975
  end
976
976
 
977
977
  opt.separator nil
@@ -1282,4 +1282,33 @@ Usage: #{opt.program_name} [options] [names...]
1282
1282
  end
1283
1283
  end
1284
1284
 
1285
+ ##
1286
+ # Loads options from .rdoc_options if the file exists, otherwise creates a
1287
+ # new RDoc::Options instance.
1288
+
1289
+ def self.load_options
1290
+ options_file = File.expand_path '.rdoc_options'
1291
+ return RDoc::Options.new unless File.exist? options_file
1292
+
1293
+ RDoc.load_yaml
1294
+
1295
+ begin
1296
+ options = YAML.safe_load File.read('.rdoc_options'), permitted_classes: [RDoc::Options, Symbol]
1297
+ rescue Psych::SyntaxError
1298
+ raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
1299
+ end
1300
+
1301
+ return RDoc::Options.new unless options # Allow empty file.
1302
+
1303
+ raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
1304
+ RDoc::Options === options or Hash === options
1305
+
1306
+ if Hash === options
1307
+ # Override the default values with the contents of YAML file.
1308
+ options = RDoc::Options.new options
1309
+ end
1310
+
1311
+ options
1312
+ end
1313
+
1285
1314
  end
data/lib/rdoc/parser/c.rb CHANGED
@@ -173,6 +173,8 @@ class RDoc::Parser::C < RDoc::Parser
173
173
  @classes = load_variable_map :c_class_variables
174
174
  @singleton_classes = load_variable_map :c_singleton_class_variables
175
175
 
176
+ @markup = @options.markup
177
+
176
178
  # class_variable => { function => [method, ...] }
177
179
  @methods = Hash.new { |h, f| h[f] = Hash.new { |i, m| i[m] = [] } }
178
180
 
@@ -439,7 +441,7 @@ class RDoc::Parser::C < RDoc::Parser
439
441
  next unless cls = @classes[c]
440
442
  m = @known_classes[m] || m
441
443
 
442
- comment = RDoc::Comment.new '', @top_level, :c
444
+ comment = new_comment '', @top_level, :c
443
445
  incl = cls.add_include RDoc::Include.new(m, comment)
444
446
  incl.record_location @top_level
445
447
  end
@@ -521,7 +523,7 @@ class RDoc::Parser::C < RDoc::Parser
521
523
  \s*"#{Regexp.escape new_name}"\s*,
522
524
  \s*"#{Regexp.escape old_name}"\s*\);%xm
523
525
 
524
- RDoc::Comment.new($1 || '', @top_level, :c)
526
+ new_comment($1 || '', @top_level, :c)
525
527
  end
526
528
 
527
529
  ##
@@ -560,7 +562,7 @@ class RDoc::Parser::C < RDoc::Parser
560
562
  ''
561
563
  end
562
564
 
563
- RDoc::Comment.new comment, @top_level, :c
565
+ new_comment comment, @top_level, :c
564
566
  end
565
567
 
566
568
  ##
@@ -600,7 +602,7 @@ class RDoc::Parser::C < RDoc::Parser
600
602
 
601
603
  case type
602
604
  when :func_def
603
- comment = RDoc::Comment.new args[0], @top_level, :c
605
+ comment = new_comment args[0], @top_level, :c
604
606
  body = args[1]
605
607
  offset, = args[2]
606
608
 
@@ -630,7 +632,7 @@ class RDoc::Parser::C < RDoc::Parser
630
632
 
631
633
  body
632
634
  when :macro_def
633
- comment = RDoc::Comment.new args[0], @top_level, :c
635
+ comment = new_comment args[0], @top_level, :c
634
636
  body = args[1]
635
637
  offset, = args[2]
636
638
 
@@ -737,7 +739,7 @@ class RDoc::Parser::C < RDoc::Parser
737
739
  comment = ''
738
740
  end
739
741
 
740
- comment = RDoc::Comment.new comment, @top_level, :c
742
+ comment = new_comment comment, @top_level, :c
741
743
  comment.normalize
742
744
 
743
745
  look_for_directives_in class_mod, comment
@@ -782,7 +784,7 @@ class RDoc::Parser::C < RDoc::Parser
782
784
  table[const_name] ||
783
785
  ''
784
786
 
785
- RDoc::Comment.new comment, @top_level, :c
787
+ new_comment comment, @top_level, :c
786
788
  end
787
789
 
788
790
  ##
@@ -813,7 +815,7 @@ class RDoc::Parser::C < RDoc::Parser
813
815
 
814
816
  return unless comment
815
817
 
816
- RDoc::Comment.new comment, @top_level, :c
818
+ new_comment comment, @top_level, :c
817
819
  end
818
820
 
819
821
  ##
@@ -947,7 +949,7 @@ class RDoc::Parser::C < RDoc::Parser
947
949
 
948
950
  new_comment = "#{$1}#{new_comment.lstrip}"
949
951
 
950
- new_comment = RDoc::Comment.new new_comment, @top_level, :c
952
+ new_comment = self.new_comment(new_comment, @top_level, :c)
951
953
 
952
954
  con = RDoc::Constant.new const_name, new_definition, new_comment
953
955
  else
@@ -1028,7 +1030,12 @@ class RDoc::Parser::C < RDoc::Parser
1028
1030
 
1029
1031
 
1030
1032
  meth_obj.record_location @top_level
1033
+
1034
+ if meth_obj.section_title
1035
+ class_obj.temporary_section = class_obj.add_section(meth_obj.section_title)
1036
+ end
1031
1037
  class_obj.add_method meth_obj
1038
+
1032
1039
  @stats.add_method meth_obj
1033
1040
  meth_obj.visibility = :private if 'private_method' == type
1034
1041
  end
@@ -1222,4 +1229,9 @@ class RDoc::Parser::C < RDoc::Parser
1222
1229
  @top_level
1223
1230
  end
1224
1231
 
1232
+ def new_comment text = nil, location = nil, language = nil
1233
+ RDoc::Comment.new(text, location, language).tap do |comment|
1234
+ comment.format = @markup
1235
+ end
1236
+ end
1225
1237
  end
@@ -1193,6 +1193,22 @@ class RDoc::Parser::Ruby < RDoc::Parser
1193
1193
  end
1194
1194
  end
1195
1195
 
1196
+ ##
1197
+ # Parses an +included+ with a block feature of ActiveSupport::Concern.
1198
+
1199
+ def parse_included_with_activesupport_concern container, comment # :nodoc:
1200
+ skip_tkspace_without_nl
1201
+ tk = get_tk
1202
+ unless tk[:kind] == :on_lbracket || (tk[:kind] == :on_kw && tk[:text] == 'do')
1203
+ unget_tk tk
1204
+ return nil # should be a block
1205
+ end
1206
+
1207
+ parse_statements container
1208
+
1209
+ container
1210
+ end
1211
+
1196
1212
  ##
1197
1213
  # Parses identifiers that can create new methods or change visibility.
1198
1214
  #
@@ -1893,6 +1909,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
1893
1909
  parse_extend_or_include RDoc::Include, container, comment
1894
1910
  when "extend" then
1895
1911
  parse_extend_or_include RDoc::Extend, container, comment
1912
+ when "included" then
1913
+ parse_included_with_activesupport_concern container, comment
1896
1914
  end
1897
1915
 
1898
1916
  else
@@ -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.7.3
5
- # from Racc grammar file "block_parser.ry".
4
+ # This file is automatically generated by Racc 1.5.2
5
+ # from Racc grammar file "".
6
6
  #
7
7
 
8
8
  require 'racc/parser.rb'
@@ -620,7 +620,6 @@ 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)
624
623
 
625
624
  Racc_token_to_s_table = [
626
625
  "$end",
@@ -671,7 +670,6 @@ Racc_token_to_s_table = [
671
670
  "blocks_in_list",
672
671
  "block_in_list",
673
672
  "whitelines2" ]
674
- Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
675
673
 
676
674
  Racc_debug_parser = false
677
675
 
@@ -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.7.3
5
- # from Racc grammar file "inline_parser.ry".
4
+ # This file is automatically generated by Racc 1.5.2
5
+ # from Racc grammar file "".
6
6
  #
7
7
 
8
8
  require 'racc/parser.rb'
@@ -652,7 +652,6 @@ 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)
656
655
 
657
656
  Racc_token_to_s_table = [
658
657
  "$end",
@@ -724,7 +723,6 @@ Racc_token_to_s_table = [
724
723
  "normal_strings",
725
724
  "verb_string",
726
725
  "verb_normal_string" ]
727
- Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
728
726
 
729
727
  Racc_debug_parser = false
730
728
 
data/lib/rdoc/rdoc.rb CHANGED
@@ -14,7 +14,7 @@ require 'time'
14
14
  # is:
15
15
  #
16
16
  # rdoc = RDoc::RDoc.new
17
- # options = rdoc.load_options # returns an RDoc::Options instance
17
+ # options = RDoc::Options.load_options # returns an RDoc::Options instance
18
18
  # # set extra options
19
19
  # rdoc.document options
20
20
  #
@@ -151,35 +151,6 @@ class RDoc::RDoc
151
151
  end
152
152
  end
153
153
 
154
- ##
155
- # Loads options from .rdoc_options if the file exists, otherwise creates a
156
- # new RDoc::Options instance.
157
-
158
- def load_options
159
- options_file = File.expand_path '.rdoc_options'
160
- return RDoc::Options.new unless File.exist? options_file
161
-
162
- RDoc.load_yaml
163
-
164
- begin
165
- options = YAML.safe_load_file '.rdoc_options', permitted_classes: [RDoc::Options, Symbol]
166
- rescue Psych::SyntaxError
167
- raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
168
- end
169
-
170
- return RDoc::Options.new unless options # Allow empty file.
171
-
172
- raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
173
- RDoc::Options === options or Hash === options
174
-
175
- if Hash === options
176
- # Override the default values with the contents of YAML file.
177
- options = RDoc::Options.new options
178
- end
179
-
180
- options
181
- end
182
-
183
154
  ##
184
155
  # Create an output dir if it doesn't exist. If it does exist, but doesn't
185
156
  # contain the flag file <tt>created.rid</tt> then we refuse to use it, as
@@ -471,7 +442,7 @@ The internal error was:
471
442
  @options = options
472
443
  @options.finish
473
444
  else
474
- @options = load_options
445
+ @options = RDoc::Options.load_options
475
446
  @options.parse options
476
447
  end
477
448
 
@@ -142,6 +142,8 @@ Where name can be:
142
142
 
143
143
  gem_name: | gem_name:README | gem_name:History
144
144
 
145
+ ruby: | ruby:NEWS | ruby:globals
146
+
145
147
  All class names may be abbreviated to their minimum unambiguous form.
146
148
  If a name is ambiguous, all valid options will be listed.
147
149
 
@@ -153,6 +155,10 @@ they're contained in. If the gem name is followed by a ':' all files in the
153
155
  gem will be shown. The file name extension may be omitted where it is
154
156
  unambiguous.
155
157
 
158
+ 'ruby' can be used as a pseudo gem name to display files from the Ruby
159
+ core documentation. Use 'ruby:' by itself to get a list of all available
160
+ core documentation files.
161
+
156
162
  For example:
157
163
 
158
164
  #{opt.program_name} Fil
@@ -160,6 +166,7 @@ For example:
160
166
  #{opt.program_name} File.new
161
167
  #{opt.program_name} zip
162
168
  #{opt.program_name} rdoc:README
169
+ #{opt.program_name} ruby:comments
163
170
 
164
171
  Note that shell quoting or escaping may be required for method names
165
172
  containing punctuation:
@@ -609,11 +616,11 @@ or the PAGER environment variable.
609
616
 
610
617
  stores = classes[current]
611
618
 
612
- break unless stores and not stores.empty?
619
+ next unless stores and not stores.empty?
613
620
 
614
- klasses = stores.map do |store|
615
- store.ancestors[current]
616
- end.flatten.uniq
621
+ klasses = stores.flat_map do |store|
622
+ store.ancestors[current] || []
623
+ end.uniq
617
624
 
618
625
  klasses = klasses - seen
619
626
 
@@ -120,7 +120,9 @@ class RDoc::RubygemsHook
120
120
  options.exclude ||= [] # TODO maybe move to RDoc::Options#finish
121
121
  options.setup_generator generator
122
122
  options.op_dir = destination
123
- options.finish
123
+ Dir.chdir @spec.full_gem_path do
124
+ options.finish
125
+ end
124
126
 
125
127
  generator = options.generator.new @rdoc.store, options
126
128
 
data/lib/rdoc/store.rb CHANGED
@@ -556,7 +556,9 @@ class RDoc::Store
556
556
  def load_cache
557
557
  #orig_enc = @encoding
558
558
 
559
- @cache = marshal_load(cache_path)
559
+ File.open cache_path, 'rb' do |io|
560
+ @cache = Marshal.load io.read
561
+ end
560
562
 
561
563
  load_enc = @cache[:encoding]
562
564
 
@@ -613,7 +615,9 @@ class RDoc::Store
613
615
  def load_class_data klass_name
614
616
  file = class_file klass_name
615
617
 
616
- marshal_load(file)
618
+ File.open file, 'rb' do |io|
619
+ Marshal.load io.read
620
+ end
617
621
  rescue Errno::ENOENT => e
618
622
  error = MissingFileError.new(self, file, klass_name)
619
623
  error.set_backtrace e.backtrace
@@ -626,10 +630,14 @@ class RDoc::Store
626
630
  def load_method klass_name, method_name
627
631
  file = method_file klass_name, method_name
628
632
 
629
- obj = marshal_load(file)
630
- obj.store = self
631
- obj.parent ||= find_class_or_module(klass_name) || load_class(klass_name)
632
- obj
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
633
641
  rescue Errno::ENOENT => e
634
642
  error = MissingFileError.new(self, file, klass_name + method_name)
635
643
  error.set_backtrace e.backtrace
@@ -642,9 +650,11 @@ class RDoc::Store
642
650
  def load_page page_name
643
651
  file = page_file page_name
644
652
 
645
- obj = marshal_load(file)
646
- obj.store = self
647
- obj
653
+ File.open file, 'rb' do |io|
654
+ obj = Marshal.load io.read
655
+ obj.store = self
656
+ obj
657
+ end
648
658
  rescue Errno::ENOENT => e
649
659
  error = MissingFileError.new(self, file, page_name)
650
660
  error.set_backtrace e.backtrace
@@ -966,21 +976,4 @@ class RDoc::Store
966
976
  @unique_modules
967
977
  end
968
978
 
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
-
986
979
  end
data/lib/rdoc/text.rb CHANGED
@@ -218,10 +218,10 @@ module RDoc::Text
218
218
  when s.scan(/\.\.\.(\.?)/) then
219
219
  html << s[1] << encoded[:ellipsis]
220
220
  after_word = nil
221
- when s.scan(/\(c\)/) then
221
+ when s.scan(/\(c\)/i) then
222
222
  html << encoded[:copyright]
223
223
  after_word = nil
224
- when s.scan(/\(r\)/) then
224
+ when s.scan(/\(r\)/i) then
225
225
  html << encoded[:trademark]
226
226
  after_word = nil
227
227
  when s.scan(/---/) then
@@ -237,10 +237,18 @@ module RDoc::Text
237
237
  when s.scan(/``/) then # backtick double quote
238
238
  html << encoded[:open_dquote]
239
239
  after_word = nil
240
- when s.scan(/''/) then # tick double quote
240
+ when s.scan(/(?:&#39;|'){2}/) then # tick double quote
241
241
  html << encoded[:close_dquote]
242
242
  after_word = nil
243
- when s.scan(/'/) then # single quote
243
+ when s.scan(/`/) then # backtick
244
+ if insquotes or after_word
245
+ html << '`'
246
+ after_word = false
247
+ else
248
+ html << encoded[:open_squote]
249
+ insquotes = true
250
+ end
251
+ when s.scan(/&#39;|'/) then # single quote
244
252
  if insquotes
245
253
  html << encoded[:close_squote]
246
254
  insquotes = false
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.4.1'
6
+ VERSION = '6.4.0'
7
7
 
8
8
  end
data/rdoc.gemspec CHANGED
@@ -242,8 +242,8 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
242
242
  TODO.rdoc
243
243
  ]
244
244
 
245
- s.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
245
+ s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
246
246
  s.required_rubygems_version = Gem::Requirement.new(">= 2.2")
247
247
 
248
- s.add_development_dependency("gettext")
248
+ s.add_dependency 'psych', '>= 4.0.0'
249
249
  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.4.1
4
+ version: 6.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
@@ -11,24 +11,25 @@ authors:
11
11
  - Zachary Scott
12
12
  - Hiroshi SHIBATA
13
13
  - ITOYANAGI Sakura
14
+ autorequire:
14
15
  bindir: exe
15
16
  cert_chain: []
16
- date: 2024-03-21 00:00:00.000000000 Z
17
+ date: 2021-12-24 00:00:00.000000000 Z
17
18
  dependencies:
18
19
  - !ruby/object:Gem::Dependency
19
- name: gettext
20
+ name: psych
20
21
  requirement: !ruby/object:Gem::Requirement
21
22
  requirements:
22
23
  - - ">="
23
24
  - !ruby/object:Gem::Version
24
- version: '0'
25
- type: :development
25
+ version: 4.0.0
26
+ type: :runtime
26
27
  prerelease: false
27
28
  version_requirements: !ruby/object:Gem::Requirement
28
29
  requirements:
29
30
  - - ">="
30
31
  - !ruby/object:Gem::Version
31
- version: '0'
32
+ version: 4.0.0
32
33
  description: |
33
34
  RDoc produces HTML and command-line documentation for Ruby projects.
34
35
  RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentation from the command-line.
@@ -254,6 +255,7 @@ homepage: https://ruby.github.io/rdoc
254
255
  licenses:
255
256
  - Ruby
256
257
  metadata: {}
258
+ post_install_message:
257
259
  rdoc_options:
258
260
  - "--main"
259
261
  - README.rdoc
@@ -263,14 +265,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
263
265
  requirements:
264
266
  - - ">="
265
267
  - !ruby/object:Gem::Version
266
- version: 2.4.0
268
+ version: 2.5.0
267
269
  required_rubygems_version: !ruby/object:Gem::Requirement
268
270
  requirements:
269
271
  - - ">="
270
272
  - !ruby/object:Gem::Version
271
273
  version: '2.2'
272
274
  requirements: []
273
- rubygems_version: 3.6.0.dev
275
+ rubygems_version: 3.2.22
276
+ signing_key:
274
277
  specification_version: 4
275
278
  summary: RDoc produces HTML and command-line documentation for Ruby projects
276
279
  test_files: []