Class: Docscribe::Types::Sorbet::BaseProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/docscribe/types/sorbet/base_provider.rb

Overview

Shared base for Sorbet-backed signature providers.

This class parses Sorbet-style signatures through the RBS RBI prototype API and indexes them into Docscribe’s normalized signature model.

Concrete subclasses decide where the Sorbet source comes from:

  • SourceProvider => inline ‘sig` declarations in the current Ruby file

  • RBIProvider => project RBI files

Direct Known Subclasses

RBIProvider, SourceProvider

Instance Method Summary collapse

Constructor Details

#initialize(collapse_generics: false) ⇒ Object

Parameters:

  • collapse_generics (Boolean) (defaults to: false)

    whether generic container details should be simplified during formatting



21
22
23
24
25
26
# File 'lib/docscribe/types/sorbet/base_provider.rb', line 21

def initialize(collapse_generics: false)
  require 'rbs'
  @collapse_generics = !!collapse_generics
  @index = {}
  @warned = false
end

Instance Method Details

#signature_for(container:, scope:, name:) ⇒ Docscribe::Types::MethodSignature?

Look up a normalized method signature by container, scope, and name.

Parameters:

  • container (String)

    e.g. “MyModule::MyClass”

  • scope (Symbol)

    :instance or :class

  • name (Symbol, String)

    method name

Returns:



34
35
36
# File 'lib/docscribe/types/sorbet/base_provider.rb', line 34

def signature_for(container:, scope:, name:)
  @index[[normalize_container(container), scope.to_sym, name.to_sym]]
end