Module: Spoom::Sorbet::Translate
- Defined in:
- lib/spoom/sorbet/translate.rb,
lib/spoom/sorbet/translate/validator.rb,
lib/spoom/sorbet/translate/translator.rb,
lib/spoom/sorbet/translate/strip_sorbet_sigs.rb,
lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs.rb,
lib/spoom/sorbet/translate/sorbet_sigs_to_rbs_comments.rb,
lib/spoom/sorbet/translate/sorbet_assertions_to_rbs_comments.rb,
lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs/options.rb,
lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs/base_translator.rb,
lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs/line_matching_translator.rb,
lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs/human_readable_translator.rb
Defined Under Namespace
Modules: RBSCommentsToSorbetSigs, Validator Classes: Error, SorbetAssertionsToRBSComments, SorbetSigsToRBSComments, StripSorbetSigs, Translator, ValidationResult
Class Method Summary collapse
-
.rbs_comments_to_sorbet_sigs(ruby_contents, file:, max_line_length: nil, overloads_strategy: :translate_all) ⇒ Object
Converts all the RBS comments in the given Ruby code to
signodes. -
.sorbet_assertions_to_rbs_comments(ruby_contents, file:, translate_t_let: true, translate_t_cast: true, translate_t_bind: true, translate_t_must: true, translate_t_unsafe: true) ⇒ Object
Converts all
T.letandT.castnodes to RBS comments in the given Ruby code. -
.sorbet_sigs_to_rbs_comments(ruby_contents, file:, positional_names: true, max_line_length: nil, translate_generics: true, translate_helpers: true, translate_abstract_methods: true) ⇒ Object
Converts all
signodes to RBS comments in the given Ruby code. -
.strip_sorbet_sigs(ruby_contents, file:) ⇒ Object
Deletes all
signodes from the given Ruby code.
Class Method Details
.rbs_comments_to_sorbet_sigs(ruby_contents, file:, max_line_length: nil, overloads_strategy: :translate_all) ⇒ Object
Converts all the RBS comments in the given Ruby code to sig nodes.
It also handles type members and class annotations.
: (String ruby_contents, file: String, ?max_line_length: Integer?, ?overloads_strategy: Symbol) -> String
58 59 60 61 62 63 64 65 |
# File 'lib/spoom/sorbet/translate.rb', line 58 def rbs_comments_to_sorbet_sigs(ruby_contents, file:, max_line_length: nil, overloads_strategy: :translate_all) RBSCommentsToSorbetSigs.rewrite_if_needed( ruby_contents, file: file, max_line_length: max_line_length, overloads_strategy: overloads_strategy, ) end |
.sorbet_assertions_to_rbs_comments(ruby_contents, file:, translate_t_let: true, translate_t_cast: true, translate_t_bind: true, translate_t_must: true, translate_t_unsafe: true) ⇒ Object
Converts all T.let and T.cast nodes to RBS comments in the given Ruby code.
It also handles type members and class annotations.
: (
| String,
| file: String,
| ?translate_t_let: bool,
| ?translate_t_cast: bool,
| ?translate_t_bind: bool,
| ?translate_t_must: bool,
| ?translate_t_unsafe: bool
| ) -> String
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/spoom/sorbet/translate.rb', line 78 def sorbet_assertions_to_rbs_comments( ruby_contents, file:, translate_t_let: true, translate_t_cast: true, translate_t_bind: true, translate_t_must: true, translate_t_unsafe: true ) SorbetAssertionsToRBSComments.new( ruby_contents, file: file, translate_t_let: translate_t_let, translate_t_cast: translate_t_cast, translate_t_bind: translate_t_bind, translate_t_must: translate_t_must, translate_t_unsafe: translate_t_unsafe, ).rewrite end |
.sorbet_sigs_to_rbs_comments(ruby_contents, file:, positional_names: true, max_line_length: nil, translate_generics: true, translate_helpers: true, translate_abstract_methods: true) ⇒ Object
Converts all sig nodes to RBS comments in the given Ruby code.
It also handles type members and class annotations.
: (
| String,
| file: String,
| ?positional_names: bool,
| ?max_line_length: Integer?,
| ?translate_generics: bool,
| ?translate_helpers: bool,
| ?translate_abstract_methods: bool
| ) -> String
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/spoom/sorbet/translate.rb', line 38 def sorbet_sigs_to_rbs_comments( ruby_contents, file:, positional_names: true, max_line_length: nil, translate_generics: true, translate_helpers: true, translate_abstract_methods: true ) SorbetSigsToRBSComments.new( ruby_contents, file: file, positional_names: positional_names, max_line_length: max_line_length, translate_generics: translate_generics, translate_helpers: translate_helpers, translate_abstract_methods: translate_abstract_methods, ).rewrite end |
.strip_sorbet_sigs(ruby_contents, file:) ⇒ Object
Deletes all sig nodes from the given Ruby code.
It doesn't handle type members and class annotations.
: (String ruby_contents, file: String) -> String
23 24 25 |
# File 'lib/spoom/sorbet/translate.rb', line 23 def strip_sorbet_sigs(ruby_contents, file:) StripSorbetSigs.new(ruby_contents, file: file).rewrite end |