rdoc 6.3.0 → 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.

@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'time'
3
2
 
4
3
  ##
5
4
  # A ChangeLog file parser.
@@ -106,14 +105,32 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
106
105
  entries.group_by do |title, _|
107
106
  begin
108
107
  time = @time_cache[title]
109
- (time || Time.parse(title)).strftime '%Y-%m-%d'
108
+ (time || parse_date(title)).strftime '%Y-%m-%d'
110
109
  rescue NoMethodError, ArgumentError
111
110
  time, = title.split ' ', 2
112
- Time.parse(time).strftime '%Y-%m-%d'
111
+ parse_date(time).strftime '%Y-%m-%d'
113
112
  end
114
113
  end
115
114
  end
116
115
 
116
+ ##
117
+ # Parse date in ISO-8601, RFC-2822, or default of Git
118
+
119
+ def parse_date(date)
120
+ case date
121
+ when /\A\s*(\d+)-(\d+)-(\d+)(?:[ T](\d+):(\d+):(\d+) *([-+]\d\d):?(\d\d))?\b/
122
+ Time.new($1, $2, $3, $4, $5, $6, ("#{$7}:#{$8}" if $7))
123
+ when /\A\s*\w{3}, +(\d+) (\w{3}) (\d+) (\d+):(\d+):(\d+) *(?:([-+]\d\d):?(\d\d))\b/
124
+ Time.new($3, $2, $1, $4, $5, $6, ("#{$7}:#{$8}" if $7))
125
+ when /\A\s*\w{3} (\w{3}) +(\d+) (\d+) (\d+):(\d+):(\d+) *(?:([-+]\d\d):?(\d\d))\b/
126
+ Time.new($3, $1, $2, $4, $5, $6, ("#{$7}:#{$8}" if $7))
127
+ when /\A\s*\w{3} (\w{3}) +(\d+) (\d+):(\d+):(\d+) (\d+)\b/
128
+ Time.new($6, $1, $2, $3, $4, $5)
129
+ else
130
+ raise ArgumentError, "bad date: #{date}"
131
+ end
132
+ end
133
+
117
134
  ##
118
135
  # Parses the entries in the ChangeLog.
119
136
  #
@@ -131,6 +148,13 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
131
148
 
132
149
  def parse_entries
133
150
  @time_cache ||= {}
151
+
152
+ if /\A((?:.*\n){,3})commit\s/ =~ @content
153
+ class << self; prepend Git; end
154
+ parse_info($1)
155
+ return parse_entries
156
+ end
157
+
134
158
  entries = []
135
159
  entry_name = nil
136
160
  entry_body = []
@@ -145,19 +169,10 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
145
169
  entry_name = $&
146
170
 
147
171
  begin
148
- time = Time.parse entry_name
172
+ time = parse_date entry_name
149
173
  @time_cache[entry_name] = time
150
- # HACK Ruby 1.8 does not raise ArgumentError for Time.parse "Other"
151
- entry_name = nil unless entry_name =~ /#{time.year}/
152
- rescue NoMethodError
153
- # HACK Ruby 2.1.2 and earlier raises NoMethodError if time part is absent
154
- entry_name.split ' ', 2
155
174
  rescue ArgumentError
156
- if /out of range/ =~ $!.message
157
- Time.parse(entry_name.split(' ', 2)[0]) rescue entry_name = nil
158
- else
159
- entry_name = nil
160
- end
175
+ entry_name = nil
161
176
  end
162
177
 
163
178
  entry_body = []
@@ -190,6 +205,7 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
190
205
 
191
206
  def scan
192
207
  @time_cache = {}
208
+
193
209
  entries = parse_entries
194
210
  grouped_entries = group_entries entries
195
211
 
@@ -200,5 +216,120 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
200
216
  @top_level
201
217
  end
202
218
 
219
+ module Git
220
+ def parse_info(info)
221
+ /^\s*base-url\s*=\s*(.*\S)/ =~ info
222
+ @base_url = $1
223
+ end
224
+
225
+ def parse_entries
226
+ entries = []
227
+
228
+ @content.scan(/^commit\s+(\h{20})\h*\n((?:.+\n)*)\n((?: {4}.*\n+)*)/) do
229
+ entry_name, header, entry_body = $1, $2, $3.gsub(/^ {4}/, '')
230
+ # header = header.scan(/^ *(\S+?): +(.*)/).to_h
231
+ # date = header["CommitDate"] || header["Date"]
232
+ date = header[/^ *(?:Author)?Date: +(.*)/, 1]
233
+ author = header[/^ *Author: +(.*)/, 1]
234
+ begin
235
+ time = parse_date(header[/^ *CommitDate: +(.*)/, 1] || date)
236
+ @time_cache[entry_name] = time
237
+ author.sub!(/\s*<(.*)>/, '')
238
+ email = $1
239
+ entries << [entry_name, [author, email, date, entry_body]]
240
+ rescue ArgumentError
241
+ end
242
+ end
243
+
244
+ entries
245
+ end
246
+
247
+ def create_entries entries
248
+ # git log entries have no strictly itemized style like the old
249
+ # style, just assume Markdown.
250
+ entries.map do |commit, entry|
251
+ LogEntry.new(@base_url, commit, *entry)
252
+ end
253
+ end
254
+
255
+ LogEntry = Struct.new(:base, :commit, :author, :email, :date, :contents) do
256
+ HEADING_LEVEL = 3
257
+
258
+ def initialize(base, commit, author, email, date, contents)
259
+ case contents
260
+ when String
261
+ contents = RDoc::Markdown.parse(contents).parts.each do |body|
262
+ case body
263
+ when RDoc::Markup::Heading
264
+ body.level += HEADING_LEVEL + 1
265
+ end
266
+ end
267
+ case first = contents[0]
268
+ when RDoc::Markup::Paragraph
269
+ contents[0] = RDoc::Markup::Heading.new(HEADING_LEVEL + 1, first.text)
270
+ end
271
+ end
272
+ super
273
+ end
274
+
275
+ def level
276
+ HEADING_LEVEL
277
+ end
278
+
279
+ def aref
280
+ "label-#{commit}"
281
+ end
282
+
283
+ def label context = nil
284
+ aref
285
+ end
286
+
287
+ def text
288
+ case base
289
+ when nil
290
+ "#{date}"
291
+ when /%s/
292
+ "{#{date}}[#{base % commit}]"
293
+ else
294
+ "{#{date}}[#{base}#{commit}]"
295
+ end + " {#{author}}[mailto:#{email}]"
296
+ end
297
+
298
+ def accept visitor
299
+ visitor.accept_heading self
300
+ begin
301
+ if visitor.respond_to?(:code_object=)
302
+ code_object = visitor.code_object
303
+ visitor.code_object = self
304
+ end
305
+ contents.each do |body|
306
+ body.accept visitor
307
+ end
308
+ ensure
309
+ if visitor.respond_to?(:code_object)
310
+ visitor.code_object = code_object
311
+ end
312
+ end
313
+ end
314
+
315
+ def pretty_print q # :nodoc:
316
+ q.group(2, '[log_entry: ', ']') do
317
+ q.text commit
318
+ q.text ','
319
+ q.breakable
320
+ q.group(2, '[date: ', ']') { q.text date }
321
+ q.text ','
322
+ q.breakable
323
+ q.group(2, '[author: ', ']') { q.text author }
324
+ q.text ','
325
+ q.breakable
326
+ q.group(2, '[email: ', ']') { q.text email }
327
+ q.text ','
328
+ q.breakable
329
+ q.pp contents
330
+ end
331
+ end
332
+ end
333
+ end
203
334
  end
204
335
 
@@ -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,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
3
  # DO NOT MODIFY!!!!
4
- # This file is automatically generated by Racc 1.5.1
4
+ # This file is automatically generated by Racc 1.5.2
5
5
  # from Racc grammar file "".
6
6
  #
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
3
  # DO NOT MODIFY!!!!
4
- # This file is automatically generated by Racc 1.5.1
4
+ # This file is automatically generated by Racc 1.5.2
5
5
  # from Racc grammar file "".
6
6
  #
7
7
 
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,27 +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.load_file '.rdoc_options'
166
- rescue Psych::SyntaxError
167
- end
168
-
169
- raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
170
- RDoc::Options === options
171
-
172
- options
173
- end
174
-
175
154
  ##
176
155
  # Create an output dir if it doesn't exist. If it does exist, but doesn't
177
156
  # contain the flag file <tt>created.rid</tt> then we refuse to use it, as
@@ -436,7 +415,7 @@ The internal error was:
436
415
  files.reject do |file, *|
437
416
  file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)$/i or
438
417
  (file =~ /tags$/i and
439
- open(file, 'rb') { |io|
418
+ File.open(file, 'rb') { |io|
440
419
  io.read(100) =~ /\A(\f\n[^,]+,\d+$|!_TAG_)/
441
420
  })
442
421
  end
@@ -463,7 +442,7 @@ The internal error was:
463
442
  @options = options
464
443
  @options.finish
465
444
  else
466
- @options = load_options
445
+ @options = RDoc::Options.load_options
467
446
  @options.parse options
468
447
  end
469
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/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.0'
6
+ VERSION = '6.4.0'
7
7
 
8
8
  end
data/rdoc.gemspec CHANGED
@@ -50,7 +50,6 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
50
50
  "bin/setup",
51
51
  "exe/rdoc",
52
52
  "exe/ri",
53
- "man/ri.1",
54
53
  "lib/rdoc.rb",
55
54
  "lib/rdoc/alias.rb",
56
55
  "lib/rdoc/anon_class.rb",
@@ -167,6 +166,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
167
166
  "lib/rdoc/markup/raw.rb",
168
167
  "lib/rdoc/markup/regexp_handling.rb",
169
168
  "lib/rdoc/markup/rule.rb",
169
+ "lib/rdoc/markup/table.rb",
170
170
  "lib/rdoc/markup/to_ansi.rb",
171
171
  "lib/rdoc/markup/to_bs.rb",
172
172
  "lib/rdoc/markup/to_html.rb",
@@ -222,6 +222,7 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
222
222
  "lib/rdoc/tom_doc.rb",
223
223
  "lib/rdoc/top_level.rb",
224
224
  "lib/rdoc/version.rb",
225
+ "man/ri.1",
225
226
  "rdoc.gemspec",
226
227
  ]
227
228
  # files from .gitignore
@@ -241,6 +242,8 @@ RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentat
241
242
  TODO.rdoc
242
243
  ]
243
244
 
244
- s.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
245
+ s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
245
246
  s.required_rubygems_version = Gem::Requirement.new(">= 2.2")
247
+
248
+ s.add_dependency 'psych', '>= 4.0.0'
246
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.0
4
+ version: 6.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
@@ -14,8 +14,22 @@ authors:
14
14
  autorequire:
15
15
  bindir: exe
16
16
  cert_chain: []
17
- date: 2020-12-21 00:00:00.000000000 Z
18
- dependencies: []
17
+ date: 2021-12-24 00:00:00.000000000 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: psych
21
+ requirement: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 4.0.0
26
+ type: :runtime
27
+ prerelease: false
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 4.0.0
19
33
  description: |
20
34
  RDoc produces HTML and command-line documentation for Ruby projects.
21
35
  RDoc includes the +rdoc+ and +ri+ tools for generating and displaying documentation from the command-line.
@@ -177,6 +191,7 @@ files:
177
191
  - lib/rdoc/markup/raw.rb
178
192
  - lib/rdoc/markup/regexp_handling.rb
179
193
  - lib/rdoc/markup/rule.rb
194
+ - lib/rdoc/markup/table.rb
180
195
  - lib/rdoc/markup/to_ansi.rb
181
196
  - lib/rdoc/markup/to_bs.rb
182
197
  - lib/rdoc/markup/to_html.rb
@@ -250,14 +265,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
250
265
  requirements:
251
266
  - - ">="
252
267
  - !ruby/object:Gem::Version
253
- version: 2.4.0
268
+ version: 2.5.0
254
269
  required_rubygems_version: !ruby/object:Gem::Requirement
255
270
  requirements:
256
271
  - - ">="
257
272
  - !ruby/object:Gem::Version
258
273
  version: '2.2'
259
274
  requirements: []
260
- rubygems_version: 3.2.2
275
+ rubygems_version: 3.2.22
261
276
  signing_key:
262
277
  specification_version: 4
263
278
  summary: RDoc produces HTML and command-line documentation for Ruby projects