Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert the utils/tty RBI generator to a Tapioca compiler #16899

Merged
merged 5 commits into from Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion Library/Homebrew/dev-cmd/typecheck.rb
Expand Up @@ -51,7 +51,6 @@ def run
tapioca_args = args.update_all? ? ["--all"] : []

ohai "Updating homegrown RBI files..."
safe_system "bundle", "exec", "ruby", "sorbet/custom_generators/tty.rb"
safe_system "bundle", "exec", "ruby", "sorbet/custom_generators/env_config.rb"

ohai "Updating Tapioca RBI files..."
Expand Down
31 changes: 0 additions & 31 deletions Library/Homebrew/sorbet/custom_generators/tty.rb

This file was deleted.

66 changes: 66 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/tty.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Library/Homebrew/sorbet/tapioca/compilers/tty.rb
@@ -0,0 +1,30 @@
# typed: strict
# frozen_string_literal: true

require_relative "../../../global"
require "utils/tty"

module Tapioca
module Compilers
class Tty < Tapioca::Dsl::Compiler
# FIXME: Enable cop again when https://github.com/sorbet/sorbet/issues/3532 is fixed.
# rubocop:disable Style/MutableConstant
ConstantType = type_member { { fixed: Module } }
# rubocop:enable Style/MutableConstant

sig { override.returns(T::Enumerable[Module]) }
def self.gather_constants = [::Tty]

sig { override.void }
def decorate
root.create_module(T.must(constant.name)) do |mod|
dynamic_methods = ::Tty::COLOR_CODES.keys + ::Tty::STYLE_CODES.keys + ::Tty::SPECIAL_CODES.keys

dynamic_methods.each do |method|
mod.create_method(method.to_s, return_type: "String", class_method: true)
end
end
end
end
end
end
60 changes: 0 additions & 60 deletions Library/Homebrew/utils/tty.rbi

This file was deleted.