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, erase_generic_types: false, force: false) ⇒ 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, preserve_multiline_signatures: 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, erase_generic_types: false, force: false) ⇒ 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, ?erase_generic_types: bool, ?force: bool) -> String
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/spoom/sorbet/translate.rb', line 64 def rbs_comments_to_sorbet_sigs(ruby_contents, file:, max_line_length: nil, overloads_strategy: :translate_all, erase_generic_types: false, force: false) RBSCommentsToSorbetSigs.rewrite_if_needed( ruby_contents, file: file, max_line_length: max_line_length, overloads_strategy: overloads_strategy, erase_generic_types: erase_generic_types, force: force, ) 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
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/spoom/sorbet/translate.rb', line 87 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, preserve_multiline_signatures: 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,
| ?preserve_multiline_signatures: bool,
| ?max_line_length: Integer?,
| ?translate_generics: bool,
| ?translate_helpers: bool,
| ?translate_abstract_methods: bool
| ) -> String
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/spoom/sorbet/translate.rb', line 39 def sorbet_sigs_to_rbs_comments( ruby_contents, file:, positional_names: true, preserve_multiline_signatures: 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, preserve_multiline_signatures: preserve_multiline_signatures, 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 |