docscribe 1.3.1 → 1.3.2
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 +4 -4
- data/lib/docscribe/cli/config_builder.rb +1 -1
- data/lib/docscribe/cli/run.rb +35 -6
- data/lib/docscribe/inline_rewriter/doc_builder.rb +4 -4
- data/lib/docscribe/inline_rewriter.rb +11 -7
- data/lib/docscribe/types/rbs/provider.rb +18 -1
- data/lib/docscribe/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 765dd81d49b3cbf47c90f83f9e533a367da6590f84b15ca7e49de66c6140b5e1
|
|
4
|
+
data.tar.gz: b7c0607de2fb6e2344be24d4da58c1e03ab33755175783e1e6de8c934a8f2cdc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f30b33860317c5b9914e6b6c633df75c35f11883d7524c3b832365431a5f47760eaaeb4daab3b20f358bad8cb088015b173d6848bf65b3d7cbba18a69fda5154
|
|
7
|
+
data.tar.gz: 66ac534ba8452880ee778ae1bf72ce571e9ea4bba481e5595172314df1f809eb62db87ec8b77cd4efb8c8cd37c85dd0c937b7fa8c263938ab46734ae03f5acda
|
|
@@ -44,7 +44,7 @@ module Docscribe
|
|
|
44
44
|
raw['filter']['files']['include'] = Array(raw['filter']['files']['include']) + options[:include_file]
|
|
45
45
|
raw['filter']['files']['exclude'] = Array(raw['filter']['files']['exclude']) + options[:exclude_file]
|
|
46
46
|
|
|
47
|
-
if options[:rbs] || options[:sig_dirs].any?
|
|
47
|
+
if options[:rbs] || options[:rbs_collection] || options[:sig_dirs].any?
|
|
48
48
|
raw['rbs'] ||= {}
|
|
49
49
|
raw['rbs']['enabled'] = true
|
|
50
50
|
raw['rbs']['sig_dirs'] = Array(raw['rbs']['sig_dirs']) + options[:sig_dirs] if options[:sig_dirs].any?
|
data/lib/docscribe/cli/run.rb
CHANGED
|
@@ -148,7 +148,9 @@ module Docscribe
|
|
|
148
148
|
fail_paths: [],
|
|
149
149
|
fail_changes: {},
|
|
150
150
|
error_paths: [],
|
|
151
|
-
error_messages: {}
|
|
151
|
+
error_messages: {},
|
|
152
|
+
type_mismatch_paths: [],
|
|
153
|
+
type_mismatch_changes: {}
|
|
152
154
|
}
|
|
153
155
|
end
|
|
154
156
|
|
|
@@ -278,9 +280,18 @@ module Docscribe
|
|
|
278
280
|
# @param [Hash] state shared processing state
|
|
279
281
|
# @return [void]
|
|
280
282
|
def handle_check_result(path, src:, out:, file_changes:, display_path:, options:, state:)
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
283
|
+
type_mismatches = file_changes.select { |c| %i[updated_param updated_return].include?(c[:type]) }
|
|
284
|
+
has_real_changes = file_changes.any? { |c| !%i[updated_param updated_return].include?(c[:type]) }
|
|
285
|
+
|
|
286
|
+
if out == src && !has_real_changes
|
|
287
|
+
if type_mismatches.any?
|
|
288
|
+
state[:type_mismatch_paths] << path
|
|
289
|
+
state[:type_mismatch_changes][path] = type_mismatches
|
|
290
|
+
options[:verbose] ? puts("MT #{display_path}") : print('M')
|
|
291
|
+
else
|
|
292
|
+
state[:checked_ok] += 1
|
|
293
|
+
options[:verbose] ? puts("OK #{display_path}") : print('.')
|
|
294
|
+
end
|
|
284
295
|
return
|
|
285
296
|
end
|
|
286
297
|
|
|
@@ -350,13 +361,22 @@ module Docscribe
|
|
|
350
361
|
puts
|
|
351
362
|
|
|
352
363
|
checked_error = state[:error_paths].size
|
|
364
|
+
type_mismatch_count = state[:type_mismatch_paths].size
|
|
353
365
|
|
|
354
|
-
if state[:checked_fail].zero? && checked_error.zero?
|
|
366
|
+
if state[:checked_fail].zero? && checked_error.zero? && type_mismatch_count.zero?
|
|
355
367
|
puts "Docscribe: OK (#{state[:checked_ok]} files checked)"
|
|
356
368
|
return
|
|
357
369
|
end
|
|
358
370
|
|
|
359
|
-
|
|
371
|
+
if state[:checked_fail].zero? && checked_error.zero?
|
|
372
|
+
puts "Docscribe: OK (#{state[:checked_ok]} files checked, #{type_mismatch_count} with type mismatches)"
|
|
373
|
+
else
|
|
374
|
+
parts = ["#{state[:checked_fail]} need updates"]
|
|
375
|
+
parts << "#{type_mismatch_count} type mismatches" if type_mismatch_count.positive?
|
|
376
|
+
parts << "#{checked_error} errors"
|
|
377
|
+
parts << "#{state[:checked_ok]} ok"
|
|
378
|
+
puts "Docscribe: FAILED (#{parts.join(', ')})"
|
|
379
|
+
end
|
|
360
380
|
|
|
361
381
|
state[:fail_paths].each do |p|
|
|
362
382
|
warn "Would update docs: #{p}"
|
|
@@ -367,6 +387,15 @@ module Docscribe
|
|
|
367
387
|
end
|
|
368
388
|
end
|
|
369
389
|
|
|
390
|
+
if options[:verbose] || options[:explain]
|
|
391
|
+
state[:type_mismatch_paths].each do |p|
|
|
392
|
+
warn "Type mismatches: #{p}"
|
|
393
|
+
Array(state[:type_mismatch_changes][p]).each do |change|
|
|
394
|
+
warn " - #{format_change_reason(change)}"
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
end
|
|
398
|
+
|
|
370
399
|
state[:error_paths].each do |p|
|
|
371
400
|
warn "Error processing: #{p}"
|
|
372
401
|
warn " #{state[:error_messages][p]}" if state[:error_messages][p]
|
|
@@ -289,10 +289,10 @@ module Docscribe
|
|
|
289
289
|
if !info[:param_names].include?(pname)
|
|
290
290
|
lines << "#{pl}\n"
|
|
291
291
|
reasons << { type: :missing_param, message: "missing @param #{pname}", extra: { param: pname } }
|
|
292
|
-
elsif info[:param_types][pname]
|
|
292
|
+
elsif external_sig && info[:param_types][pname]
|
|
293
293
|
new_type = extract_param_type_from_param_line(pl)
|
|
294
294
|
if new_type && info[:param_types][pname] != new_type
|
|
295
|
-
lines << "#{pl}\n"
|
|
295
|
+
lines << "#{pl}\n" unless strategy == :safe
|
|
296
296
|
reasons << {
|
|
297
297
|
type: :updated_param,
|
|
298
298
|
message: "updated @param #{pname} from #{info[:param_types][pname]} to #{new_type}",
|
|
@@ -318,8 +318,8 @@ module Docscribe
|
|
|
318
318
|
if !info[:has_return]
|
|
319
319
|
lines << "#{indent}# @return [#{normal_type}]\n"
|
|
320
320
|
reasons << { type: :missing_return, message: 'missing @return' }
|
|
321
|
-
elsif info[:return_type] && info[:return_type] != normal_type
|
|
322
|
-
lines << "#{indent}# @return [#{normal_type}]\n"
|
|
321
|
+
elsif external_sig && info[:return_type] && info[:return_type] != normal_type
|
|
322
|
+
lines << "#{indent}# @return [#{normal_type}]\n" unless strategy == :safe
|
|
323
323
|
reasons << {
|
|
324
324
|
type: :updated_return,
|
|
325
325
|
message: "updated @return from #{info[:return_type]} to #{normal_type}"
|
|
@@ -395,24 +395,28 @@ module Docscribe
|
|
|
395
395
|
range = Parser::Source::Range.new(buffer, info[:start_pos], info[:end_pos])
|
|
396
396
|
rewriter.replace(range, new_block)
|
|
397
397
|
|
|
398
|
-
|
|
398
|
+
if existing_order_changed
|
|
399
399
|
add_change(
|
|
400
400
|
changes,
|
|
401
|
-
type:
|
|
401
|
+
type: :unsorted_tags,
|
|
402
402
|
insertion: insertion,
|
|
403
403
|
file: file,
|
|
404
|
-
message:
|
|
405
|
-
extra: reason[:extra] || {}
|
|
404
|
+
message: 'unsorted tags'
|
|
406
405
|
)
|
|
407
406
|
end
|
|
407
|
+
end
|
|
408
408
|
|
|
409
|
-
|
|
409
|
+
type_mismatch_reasons = reason_specs.select { |r| %i[updated_param updated_return].include?(r[:type]) }
|
|
410
|
+
|
|
411
|
+
if new_block != old_block || type_mismatch_reasons.any?
|
|
412
|
+
reason_specs.each do |reason|
|
|
410
413
|
add_change(
|
|
411
414
|
changes,
|
|
412
|
-
type: :
|
|
415
|
+
type: reason[:type],
|
|
413
416
|
insertion: insertion,
|
|
414
417
|
file: file,
|
|
415
|
-
message:
|
|
418
|
+
message: reason[:message],
|
|
419
|
+
extra: reason[:extra] || {}
|
|
416
420
|
)
|
|
417
421
|
end
|
|
418
422
|
end
|
|
@@ -89,10 +89,27 @@ module Docscribe
|
|
|
89
89
|
# @param [Symbol] scope
|
|
90
90
|
# @return [Object]
|
|
91
91
|
def definition_for(container:, scope:)
|
|
92
|
-
type_name =
|
|
92
|
+
type_name = parse_type_name(absolute_const(container))
|
|
93
93
|
scope == :class ? @builder.build_singleton(type_name) : @builder.build_instance(type_name)
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
+
# Parse a fully-qualified constant string into an RBS TypeName.
|
|
97
|
+
#
|
|
98
|
+
# Uses the lower-level constructor so it works across RBS versions
|
|
99
|
+
# that may not expose `TypeName.parse`.
|
|
100
|
+
#
|
|
101
|
+
# @private
|
|
102
|
+
# @param [String] string e.g. "::Irb::Autosuggestions"
|
|
103
|
+
# @return [::RBS::TypeName]
|
|
104
|
+
def parse_type_name(string)
|
|
105
|
+
absolute = string.start_with?('::')
|
|
106
|
+
*path, name = string.delete_prefix('::').split('::').map(&:to_sym)
|
|
107
|
+
::RBS::TypeName.new(
|
|
108
|
+
name: name,
|
|
109
|
+
namespace: ::RBS::Namespace.new(path: path, absolute: absolute)
|
|
110
|
+
)
|
|
111
|
+
end
|
|
112
|
+
|
|
96
113
|
# Normalize a container name into an absolute constant path.
|
|
97
114
|
#
|
|
98
115
|
# @private
|
data/lib/docscribe/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: docscribe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- unurgunite
|
|
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
213
213
|
- !ruby/object:Gem::Version
|
|
214
214
|
version: '0'
|
|
215
215
|
requirements: []
|
|
216
|
-
rubygems_version: 4.0.
|
|
216
|
+
rubygems_version: 4.0.12
|
|
217
217
|
specification_version: 4
|
|
218
218
|
summary: Auto-generate inline YARD documentation for Ruby by analyzing code AST. Supports
|
|
219
219
|
RBS and Sorbet type signatures.
|