spoom 1.7.3 → 1.7.4
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/spoom/cli/helper.rb +1 -4
- data/lib/spoom/cli/srb/sigs.rb +22 -2
- data/lib/spoom/context/bundle.rb +1 -4
- data/lib/spoom/context/exec.rb +1 -4
- data/lib/spoom/context/file_system.rb +1 -4
- data/lib/spoom/context/git.rb +1 -4
- data/lib/spoom/context/sorbet.rb +1 -4
- data/lib/spoom/coverage/d3/base.rb +3 -6
- data/lib/spoom/coverage/d3/pie.rb +1 -4
- data/lib/spoom/coverage/d3/timeline.rb +4 -9
- data/lib/spoom/coverage/report.rb +7 -17
- data/lib/spoom/deadcode/plugins/base.rb +1 -4
- data/lib/spoom/file_tree.rb +1 -4
- data/lib/spoom/model/model.rb +6 -14
- data/lib/spoom/model/namespace_visitor.rb +1 -4
- data/lib/spoom/poset.rb +3 -8
- data/lib/spoom/sorbet/lsp/structures.rb +3 -6
- data/lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs.rb +9 -2
- data/lib/spoom/sorbet/translate/sorbet_sigs_to_rbs_comments.rb +27 -14
- data/lib/spoom/sorbet/translate.rb +6 -6
- data/lib/spoom/version.rb +1 -1
- data/rbi/spoom.rbi +26 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e63e36fda1906fc8f047e6c4abab3ab8c887035f9e7b6c4c1d2c07d55ae3adaf
|
4
|
+
data.tar.gz: bf63f0df57b0c6dbed78a6a10021a6e94cdbbddbb8e072d145805829dae78cf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51d63f6ef122e99b679f317fe2082df8956c7f0e25cf11afd612395101edf67e025698ef2e9a4deac795c0d49077e18cbf9e46771313536deb79f3aec5e31d21
|
7
|
+
data.tar.gz: bb0a342c5c8ac4bfd0a5310d2ced6541b13d0980fdab309124fca657192fcb8fefe34bde16a347d3974563989f38713a1519a389f803a7c1ace4b18e17fe1438
|
data/lib/spoom/cli/helper.rb
CHANGED
@@ -7,13 +7,10 @@ require "stringio"
|
|
7
7
|
|
8
8
|
module Spoom
|
9
9
|
module Cli
|
10
|
+
# @requires_ancestor: Thor
|
10
11
|
module Helper
|
11
|
-
extend T::Helpers
|
12
|
-
|
13
12
|
include Colorize
|
14
13
|
|
15
|
-
requires_ancestor { Thor }
|
16
|
-
|
17
14
|
# Print `message` on `$stdout`
|
18
15
|
#: (String message) -> void
|
19
16
|
def say(message)
|
data/lib/spoom/cli/srb/sigs.rb
CHANGED
@@ -16,15 +16,26 @@ module Spoom
|
|
16
16
|
desc: "Use positional names when translating from RBI to RBS",
|
17
17
|
default: true
|
18
18
|
option :include_rbi_files, type: :boolean, desc: "Include RBI files", default: false
|
19
|
+
option :max_line_length, type: :numeric, desc: "Max line length (pass 0 to disable)", default: 120
|
19
20
|
def translate(*paths)
|
20
21
|
from = options[:from]
|
21
22
|
to = options[:to]
|
23
|
+
max_line_length = options[:max_line_length]
|
22
24
|
|
23
25
|
if from == to
|
24
26
|
say_error("Can't translate signatures from `#{from}` to `#{to}`")
|
25
27
|
exit(1)
|
26
28
|
end
|
27
29
|
|
30
|
+
if max_line_length.nil? || max_line_length.zero?
|
31
|
+
max_line_length = nil
|
32
|
+
elsif max_line_length.negative?
|
33
|
+
say_error("--max-line-length can't be negative")
|
34
|
+
exit(1)
|
35
|
+
else
|
36
|
+
max_line_length = max_line_length.to_i
|
37
|
+
end
|
38
|
+
|
28
39
|
files = collect_files(paths, include_rbi_files: options[:include_rbi_files])
|
29
40
|
|
30
41
|
say("Translating signatures from `#{from}` to `#{to}` " \
|
@@ -33,11 +44,20 @@ module Spoom
|
|
33
44
|
case from
|
34
45
|
when "rbi"
|
35
46
|
transformed_files = transform_files(files) do |file, contents|
|
36
|
-
Spoom::Sorbet::Translate.sorbet_sigs_to_rbs_comments(
|
47
|
+
Spoom::Sorbet::Translate.sorbet_sigs_to_rbs_comments(
|
48
|
+
contents,
|
49
|
+
file: file,
|
50
|
+
positional_names: options[:positional_names],
|
51
|
+
max_line_length: max_line_length,
|
52
|
+
)
|
37
53
|
end
|
38
54
|
when "rbs"
|
39
55
|
transformed_files = transform_files(files) do |file, contents|
|
40
|
-
Spoom::Sorbet::Translate.rbs_comments_to_sorbet_sigs(
|
56
|
+
Spoom::Sorbet::Translate.rbs_comments_to_sorbet_sigs(
|
57
|
+
contents,
|
58
|
+
file: file,
|
59
|
+
max_line_length: max_line_length,
|
60
|
+
)
|
41
61
|
end
|
42
62
|
end
|
43
63
|
|
data/lib/spoom/context/bundle.rb
CHANGED
@@ -4,11 +4,8 @@
|
|
4
4
|
module Spoom
|
5
5
|
class Context
|
6
6
|
# Bundle features for a context
|
7
|
+
# @requires_ancestor: Context
|
7
8
|
module Bundle
|
8
|
-
extend T::Helpers
|
9
|
-
|
10
|
-
requires_ancestor { Context }
|
11
|
-
|
12
9
|
# Read the contents of the Gemfile in this context directory
|
13
10
|
#: -> String?
|
14
11
|
def read_gemfile
|
data/lib/spoom/context/exec.rb
CHANGED
@@ -22,11 +22,8 @@ module Spoom
|
|
22
22
|
|
23
23
|
class Context
|
24
24
|
# Execution features for a context
|
25
|
+
# @requires_ancestor: Context
|
25
26
|
module Exec
|
26
|
-
extend T::Helpers
|
27
|
-
|
28
|
-
requires_ancestor { Context }
|
29
|
-
|
30
27
|
# Run a command in this context directory
|
31
28
|
#: (String command, ?capture_err: bool) -> ExecResult
|
32
29
|
def exec(command, capture_err: true)
|
@@ -4,11 +4,8 @@
|
|
4
4
|
module Spoom
|
5
5
|
class Context
|
6
6
|
# File System features for a context
|
7
|
+
# @requires_ancestor: Context
|
7
8
|
module FileSystem
|
8
|
-
extend T::Helpers
|
9
|
-
|
10
|
-
requires_ancestor { Context }
|
11
|
-
|
12
9
|
# Returns the absolute path to `relative_path` in the context's directory
|
13
10
|
#: (String relative_path) -> String
|
14
11
|
def absolute_path_to(relative_path)
|
data/lib/spoom/context/git.rb
CHANGED
@@ -28,11 +28,8 @@ module Spoom
|
|
28
28
|
|
29
29
|
class Context
|
30
30
|
# Git features for a context
|
31
|
+
# @requires_ancestor: Context
|
31
32
|
module Git
|
32
|
-
extend T::Helpers
|
33
|
-
|
34
|
-
requires_ancestor { Context }
|
35
|
-
|
36
33
|
# Run a command prefixed by `git` in this context directory
|
37
34
|
#: (String command) -> ExecResult
|
38
35
|
def git(command)
|
data/lib/spoom/context/sorbet.rb
CHANGED
@@ -4,11 +4,8 @@
|
|
4
4
|
module Spoom
|
5
5
|
class Context
|
6
6
|
# Sorbet features for a context
|
7
|
+
# @requires_ancestor: Context
|
7
8
|
module Sorbet
|
8
|
-
extend T::Helpers
|
9
|
-
|
10
|
-
requires_ancestor { Context }
|
11
|
-
|
12
9
|
# Run `bundle exec srb` in this context directory
|
13
10
|
#: (*String arg, ?sorbet_bin: String?, ?capture_err: bool) -> ExecResult
|
14
11
|
def srb(*arg, sorbet_bin: nil, capture_err: true)
|
@@ -4,12 +4,8 @@
|
|
4
4
|
module Spoom
|
5
5
|
module Coverage
|
6
6
|
module D3
|
7
|
+
# @abstract
|
7
8
|
class Base
|
8
|
-
extend T::Sig
|
9
|
-
extend T::Helpers
|
10
|
-
|
11
|
-
abstract!
|
12
|
-
|
13
9
|
#: String
|
14
10
|
attr_reader :id
|
15
11
|
|
@@ -44,7 +40,8 @@ module Spoom
|
|
44
40
|
""
|
45
41
|
end
|
46
42
|
|
47
|
-
|
43
|
+
# @abstract
|
44
|
+
#: -> String
|
48
45
|
def script; end
|
49
46
|
end
|
50
47
|
end
|
@@ -6,11 +6,8 @@ require_relative "base"
|
|
6
6
|
module Spoom
|
7
7
|
module Coverage
|
8
8
|
module D3
|
9
|
+
# @abstract
|
9
10
|
class Timeline < Base
|
10
|
-
extend T::Helpers
|
11
|
-
|
12
|
-
abstract!
|
13
|
-
|
14
11
|
#: (String id, untyped data, Array[String] keys) -> void
|
15
12
|
def initialize(id, data, keys)
|
16
13
|
super(id, data)
|
@@ -120,7 +117,8 @@ module Spoom
|
|
120
117
|
HTML
|
121
118
|
end
|
122
119
|
|
123
|
-
|
120
|
+
# @abstract
|
121
|
+
#: -> String
|
124
122
|
def plot; end
|
125
123
|
|
126
124
|
#: -> String
|
@@ -324,11 +322,8 @@ module Spoom
|
|
324
322
|
end
|
325
323
|
end
|
326
324
|
|
325
|
+
# @abstract
|
327
326
|
class Stacked < Timeline
|
328
|
-
extend T::Helpers
|
329
|
-
|
330
|
-
abstract!
|
331
|
-
|
332
327
|
# @override
|
333
328
|
#: -> String
|
334
329
|
def script
|
@@ -7,11 +7,8 @@ require "erb"
|
|
7
7
|
|
8
8
|
module Spoom
|
9
9
|
module Coverage
|
10
|
+
# @abstract
|
10
11
|
class Template
|
11
|
-
extend T::Helpers
|
12
|
-
|
13
|
-
abstract!
|
14
|
-
|
15
12
|
# Create a new template from an Erb file path
|
16
13
|
#: (template: String) -> void
|
17
14
|
def initialize(template:)
|
@@ -34,12 +31,8 @@ module Spoom
|
|
34
31
|
end
|
35
32
|
end
|
36
33
|
|
34
|
+
# @abstract
|
37
35
|
class Page < Template
|
38
|
-
extend T::Sig
|
39
|
-
extend T::Helpers
|
40
|
-
|
41
|
-
abstract!
|
42
|
-
|
43
36
|
TEMPLATE = "#{Spoom::SPOOM_PATH}/templates/page.erb" #: String
|
44
37
|
|
45
38
|
#: String
|
@@ -75,7 +68,8 @@ module Spoom
|
|
75
68
|
cards.map(&:html).join("\n")
|
76
69
|
end
|
77
70
|
|
78
|
-
|
71
|
+
# @abstract
|
72
|
+
#: -> Array[Cards::Card]
|
79
73
|
def cards; end
|
80
74
|
|
81
75
|
#: -> String
|
@@ -86,8 +80,6 @@ module Spoom
|
|
86
80
|
|
87
81
|
module Cards
|
88
82
|
class Card < Template
|
89
|
-
extend T::Sig
|
90
|
-
|
91
83
|
TEMPLATE = "#{Spoom::SPOOM_PATH}/templates/card.erb" #: String
|
92
84
|
|
93
85
|
#: String?
|
@@ -101,11 +93,8 @@ module Spoom
|
|
101
93
|
end
|
102
94
|
end
|
103
95
|
|
96
|
+
# @abstract
|
104
97
|
class Erb < Card
|
105
|
-
extend T::Helpers
|
106
|
-
|
107
|
-
abstract!
|
108
|
-
|
109
98
|
#: -> void
|
110
99
|
def initialize; end # rubocop:disable Lint/MissingSuper
|
111
100
|
|
@@ -115,7 +104,8 @@ module Spoom
|
|
115
104
|
ERB.new(erb).result(get_binding)
|
116
105
|
end
|
117
106
|
|
118
|
-
|
107
|
+
# @abstract
|
108
|
+
#: -> String
|
119
109
|
def erb; end
|
120
110
|
end
|
121
111
|
|
data/lib/spoom/file_tree.rb
CHANGED
data/lib/spoom/model/model.rb
CHANGED
@@ -63,11 +63,8 @@ module Spoom
|
|
63
63
|
#
|
64
64
|
# It can be a class, module, constant, method, etc.
|
65
65
|
# A SymbolDef has a location pointing to the actual code that defines the symbol.
|
66
|
+
# @abstract
|
66
67
|
class SymbolDef
|
67
|
-
extend T::Helpers
|
68
|
-
|
69
|
-
abstract!
|
70
|
-
|
71
68
|
# The symbol this definition belongs to
|
72
69
|
#: Symbol
|
73
70
|
attr_reader :symbol
|
@@ -109,9 +106,8 @@ module Spoom
|
|
109
106
|
end
|
110
107
|
|
111
108
|
# A class or module
|
109
|
+
# @abstract
|
112
110
|
class Namespace < SymbolDef
|
113
|
-
abstract!
|
114
|
-
|
115
111
|
#: Array[SymbolDef]
|
116
112
|
attr_reader :children
|
117
113
|
|
@@ -156,9 +152,8 @@ module Spoom
|
|
156
152
|
end
|
157
153
|
|
158
154
|
# A method or an attribute accessor
|
155
|
+
# @abstract
|
159
156
|
class Property < SymbolDef
|
160
|
-
abstract!
|
161
|
-
|
162
157
|
#: Visibility
|
163
158
|
attr_reader :visibility
|
164
159
|
|
@@ -176,8 +171,8 @@ module Spoom
|
|
176
171
|
|
177
172
|
class Method < Property; end
|
178
173
|
|
174
|
+
# @abstract
|
179
175
|
class Attr < Property
|
180
|
-
abstract!
|
181
176
|
end
|
182
177
|
|
183
178
|
class AttrReader < Attr; end
|
@@ -193,11 +188,8 @@ module Spoom
|
|
193
188
|
end
|
194
189
|
|
195
190
|
# A mixin (include, prepend, extend) to a namespace
|
191
|
+
# @abstract
|
196
192
|
class Mixin
|
197
|
-
extend T::Helpers
|
198
|
-
|
199
|
-
abstract!
|
200
|
-
|
201
193
|
#: String
|
202
194
|
attr_reader :name
|
203
195
|
|
@@ -234,7 +226,7 @@ module Spoom
|
|
234
226
|
#: -> void
|
235
227
|
def initialize
|
236
228
|
@symbols = {} #: Hash[String, Symbol]
|
237
|
-
@symbols_hierarchy = Poset
|
229
|
+
@symbols_hierarchy = Poset.new #: Poset[Symbol]
|
238
230
|
end
|
239
231
|
|
240
232
|
# Get a symbol by it's full name
|
data/lib/spoom/poset.rb
CHANGED
@@ -6,13 +6,10 @@ module Spoom
|
|
6
6
|
#
|
7
7
|
# The partial order relation is a binary relation that is reflexive, antisymmetric, and transitive.
|
8
8
|
# It can be used to represent a hierarchy of classes or modules, the dependencies between gems, etc.
|
9
|
+
#: [E < Object]
|
9
10
|
class Poset
|
10
|
-
extend T::Generic
|
11
|
-
|
12
11
|
class Error < Spoom::Error; end
|
13
12
|
|
14
|
-
E = type_member { { upper: Object } }
|
15
|
-
|
16
13
|
#: -> void
|
17
14
|
def initialize
|
18
15
|
@elements = {} #: Hash[E, Element[E]]
|
@@ -35,7 +32,7 @@ module Spoom
|
|
35
32
|
element = @elements[value]
|
36
33
|
return element if element
|
37
34
|
|
38
|
-
@elements[value] = Element
|
35
|
+
@elements[value] = Element.new(value) #: Element[E]
|
39
36
|
end
|
40
37
|
|
41
38
|
# Is the given value a element in the POSet?
|
@@ -132,12 +129,10 @@ module Spoom
|
|
132
129
|
end
|
133
130
|
|
134
131
|
# An element in a POSet
|
132
|
+
#: [E < Object]
|
135
133
|
class Element
|
136
|
-
extend T::Generic
|
137
134
|
include Comparable
|
138
135
|
|
139
|
-
E = type_member { { upper: Object } }
|
140
|
-
|
141
136
|
# The value held by this element
|
142
137
|
#: E
|
143
138
|
attr_reader :value
|
@@ -6,13 +6,10 @@ require "set"
|
|
6
6
|
|
7
7
|
module Spoom
|
8
8
|
module LSP
|
9
|
+
# @interface
|
9
10
|
module PrintableSymbol
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
interface!
|
14
|
-
|
15
|
-
sig { abstract.params(printer: SymbolPrinter).void }
|
11
|
+
# @abstract
|
12
|
+
#: (SymbolPrinter printer) -> void
|
16
13
|
def accept_printer(printer); end
|
17
14
|
end
|
18
15
|
|
@@ -7,6 +7,13 @@ module Spoom
|
|
7
7
|
class RBSCommentsToSorbetSigs < Translator
|
8
8
|
include Spoom::RBS::ExtractRBSComments
|
9
9
|
|
10
|
+
#: (String, file: String, ?max_line_length: Integer?) -> void
|
11
|
+
def initialize(ruby_contents, file:, max_line_length: nil)
|
12
|
+
super(ruby_contents, file: file)
|
13
|
+
|
14
|
+
@max_line_length = max_line_length
|
15
|
+
end
|
16
|
+
|
10
17
|
# @override
|
11
18
|
#: (Prism::ClassNode node) -> void
|
12
19
|
def visit_class_node(node)
|
@@ -53,7 +60,7 @@ module Spoom
|
|
53
60
|
@rewriter << Source::Replace.new(
|
54
61
|
signature.location.start_offset,
|
55
62
|
signature.location.end_offset,
|
56
|
-
sig.string,
|
63
|
+
sig.string(max_line_length: @max_line_length),
|
57
64
|
)
|
58
65
|
rescue ::RBS::ParsingError, ::RBI::Error
|
59
66
|
# Ignore signatures with errors
|
@@ -104,7 +111,7 @@ module Spoom
|
|
104
111
|
@rewriter << Source::Replace.new(
|
105
112
|
signature.location.start_offset,
|
106
113
|
signature.location.end_offset,
|
107
|
-
sig.string,
|
114
|
+
sig.string(max_line_length: @max_line_length),
|
108
115
|
)
|
109
116
|
rescue ::RBS::ParsingError, ::RBI::Error
|
110
117
|
# Ignore signatures with errors
|
@@ -7,8 +7,8 @@ module Spoom
|
|
7
7
|
# Converts all `sig` nodes to RBS comments in the given Ruby code.
|
8
8
|
# It also handles type members and class annotations.
|
9
9
|
class SorbetSigsToRBSComments < Translator
|
10
|
-
#: (String, file: String, positional_names: bool) -> void
|
11
|
-
def initialize(ruby_contents, file:, positional_names:)
|
10
|
+
#: (String, file: String, positional_names: bool, ?max_line_length: Integer?) -> void
|
11
|
+
def initialize(ruby_contents, file:, positional_names:, max_line_length: nil)
|
12
12
|
super(ruby_contents, file: file)
|
13
13
|
|
14
14
|
@positional_names = positional_names #: bool
|
@@ -18,6 +18,7 @@ module Spoom
|
|
18
18
|
@extend_t_helpers = [] #: Array[Prism::CallNode]
|
19
19
|
@extend_t_generics = [] #: Array[Prism::CallNode]
|
20
20
|
@seen_mixes_in_class_methods = false #: bool
|
21
|
+
@max_line_length = max_line_length #: Integer?
|
21
22
|
end
|
22
23
|
|
23
24
|
# @override
|
@@ -53,12 +54,10 @@ module Spoom
|
|
53
54
|
rbi_node = builder.tree.nodes.first #: as RBI::Method
|
54
55
|
|
55
56
|
last_sigs.each do |node, sig|
|
56
|
-
out =
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
p.print("\n")
|
61
|
-
@rewriter << Source::Replace.new(node.location.start_offset, node.location.end_offset, out.string)
|
57
|
+
out = rbs_print(node.location.start_column) do |printer|
|
58
|
+
printer.print_method_sig(rbi_node, sig)
|
59
|
+
end
|
60
|
+
@rewriter << Source::Replace.new(node.location.start_offset, node.location.end_offset, out)
|
62
61
|
end
|
63
62
|
end
|
64
63
|
|
@@ -165,12 +164,10 @@ module Spoom
|
|
165
164
|
rbi_node = builder.tree.nodes.first #: as RBI::Attr
|
166
165
|
|
167
166
|
last_sigs.each do |node, sig|
|
168
|
-
out =
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
p.print("\n")
|
173
|
-
@rewriter << Source::Replace.new(node.location.start_offset, node.location.end_offset, out.string)
|
167
|
+
out = rbs_print(node.location.start_column) do |printer|
|
168
|
+
printer.print_attr_sig(rbi_node, sig)
|
169
|
+
end
|
170
|
+
@rewriter << Source::Replace.new(node.location.start_offset, node.location.end_offset, out)
|
174
171
|
end
|
175
172
|
end
|
176
173
|
|
@@ -342,6 +339,22 @@ module Spoom
|
|
342
339
|
@last_sigs = []
|
343
340
|
last_sigs
|
344
341
|
end
|
342
|
+
|
343
|
+
#: (Integer) { (RBI::RBSPrinter) -> void } -> String
|
344
|
+
def rbs_print(indent, &block)
|
345
|
+
out = StringIO.new
|
346
|
+
p = RBI::RBSPrinter.new(out: out, positional_names: @positional_names, max_line_length: @max_line_length)
|
347
|
+
block.call(p)
|
348
|
+
string = out.string
|
349
|
+
|
350
|
+
string.lines.map.with_index do |line, index|
|
351
|
+
if index == 0
|
352
|
+
"#: #{line}"
|
353
|
+
else
|
354
|
+
"#{" " * indent}#| #{line}"
|
355
|
+
end
|
356
|
+
end.join + "\n"
|
357
|
+
end
|
345
358
|
end
|
346
359
|
end
|
347
360
|
end
|
@@ -25,16 +25,16 @@ module Spoom
|
|
25
25
|
|
26
26
|
# Converts all `sig` nodes to RBS comments in the given Ruby code.
|
27
27
|
# It also handles type members and class annotations.
|
28
|
-
#: (String ruby_contents, file: String, ?positional_names: bool) -> String
|
29
|
-
def sorbet_sigs_to_rbs_comments(ruby_contents, file:, positional_names: true)
|
30
|
-
SorbetSigsToRBSComments.new(ruby_contents, file: file, positional_names: positional_names).rewrite
|
28
|
+
#: (String ruby_contents, file: String, ?positional_names: bool, ?max_line_length: Integer?) -> String
|
29
|
+
def sorbet_sigs_to_rbs_comments(ruby_contents, file:, positional_names: true, max_line_length: nil)
|
30
|
+
SorbetSigsToRBSComments.new(ruby_contents, file: file, positional_names: positional_names, max_line_length: max_line_length).rewrite
|
31
31
|
end
|
32
32
|
|
33
33
|
# Converts all the RBS comments in the given Ruby code to `sig` nodes.
|
34
34
|
# It also handles type members and class annotations.
|
35
|
-
#: (String ruby_contents, file: String) -> String
|
36
|
-
def rbs_comments_to_sorbet_sigs(ruby_contents, file:)
|
37
|
-
RBSCommentsToSorbetSigs.new(ruby_contents, file: file).rewrite
|
35
|
+
#: (String ruby_contents, file: String, ?max_line_length: Integer?) -> String
|
36
|
+
def rbs_comments_to_sorbet_sigs(ruby_contents, file:, max_line_length: nil)
|
37
|
+
RBSCommentsToSorbetSigs.new(ruby_contents, file: file, max_line_length: max_line_length).rewrite
|
38
38
|
end
|
39
39
|
|
40
40
|
# Converts all `T.let` and `T.cast` nodes to RBS comments in the given Ruby code.
|
data/lib/spoom/version.rb
CHANGED
data/rbi/spoom.rbi
CHANGED
@@ -2839,14 +2839,21 @@ Spoom::Sorbet::Sigils::VALID_STRICTNESS = T.let(T.unsafe(nil), Array)
|
|
2839
2839
|
|
2840
2840
|
module Spoom::Sorbet::Translate
|
2841
2841
|
class << self
|
2842
|
-
sig { params(ruby_contents: ::String, file: ::String).returns(::String) }
|
2843
|
-
def rbs_comments_to_sorbet_sigs(ruby_contents, file:); end
|
2842
|
+
sig { params(ruby_contents: ::String, file: ::String, max_line_length: T.nilable(::Integer)).returns(::String) }
|
2843
|
+
def rbs_comments_to_sorbet_sigs(ruby_contents, file:, max_line_length: T.unsafe(nil)); end
|
2844
2844
|
|
2845
2845
|
sig { params(ruby_contents: ::String, file: ::String).returns(::String) }
|
2846
2846
|
def sorbet_assertions_to_rbs_comments(ruby_contents, file:); end
|
2847
2847
|
|
2848
|
-
sig
|
2849
|
-
|
2848
|
+
sig do
|
2849
|
+
params(
|
2850
|
+
ruby_contents: ::String,
|
2851
|
+
file: ::String,
|
2852
|
+
positional_names: T::Boolean,
|
2853
|
+
max_line_length: T.nilable(::Integer)
|
2854
|
+
).returns(::String)
|
2855
|
+
end
|
2856
|
+
def sorbet_sigs_to_rbs_comments(ruby_contents, file:, positional_names: T.unsafe(nil), max_line_length: T.unsafe(nil)); end
|
2850
2857
|
|
2851
2858
|
sig { params(ruby_contents: ::String, file: ::String).returns(::String) }
|
2852
2859
|
def strip_sorbet_sigs(ruby_contents, file:); end
|
@@ -2858,6 +2865,9 @@ class Spoom::Sorbet::Translate::Error < ::Spoom::Error; end
|
|
2858
2865
|
class Spoom::Sorbet::Translate::RBSCommentsToSorbetSigs < ::Spoom::Sorbet::Translate::Translator
|
2859
2866
|
include ::Spoom::RBS::ExtractRBSComments
|
2860
2867
|
|
2868
|
+
sig { params(ruby_contents: ::String, file: ::String, max_line_length: T.nilable(::Integer)).void }
|
2869
|
+
def initialize(ruby_contents, file:, max_line_length: T.unsafe(nil)); end
|
2870
|
+
|
2861
2871
|
sig { override.params(node: ::Prism::CallNode).void }
|
2862
2872
|
def visit_call_node(node); end
|
2863
2873
|
|
@@ -2924,8 +2934,15 @@ end
|
|
2924
2934
|
Spoom::Sorbet::Translate::SorbetAssertionsToRBSComments::LINE_BREAK = T.let(T.unsafe(nil), Integer)
|
2925
2935
|
|
2926
2936
|
class Spoom::Sorbet::Translate::SorbetSigsToRBSComments < ::Spoom::Sorbet::Translate::Translator
|
2927
|
-
sig
|
2928
|
-
|
2937
|
+
sig do
|
2938
|
+
params(
|
2939
|
+
ruby_contents: ::String,
|
2940
|
+
file: ::String,
|
2941
|
+
positional_names: T::Boolean,
|
2942
|
+
max_line_length: T.nilable(::Integer)
|
2943
|
+
).void
|
2944
|
+
end
|
2945
|
+
def initialize(ruby_contents, file:, positional_names:, max_line_length: T.unsafe(nil)); end
|
2929
2946
|
|
2930
2947
|
sig { override.params(node: ::Prism::CallNode).void }
|
2931
2948
|
def visit_call_node(node); end
|
@@ -2970,6 +2987,9 @@ class Spoom::Sorbet::Translate::SorbetSigsToRBSComments < ::Spoom::Sorbet::Trans
|
|
2970
2987
|
sig { void }
|
2971
2988
|
def delete_extend_t_helpers; end
|
2972
2989
|
|
2990
|
+
sig { params(indent: ::Integer, block: T.proc.params(arg0: ::RBI::RBSPrinter).void).returns(::String) }
|
2991
|
+
def rbs_print(indent, &block); end
|
2992
|
+
|
2973
2993
|
sig { params(node: ::Prism::CallNode).void }
|
2974
2994
|
def visit_attr(node); end
|
2975
2995
|
|