Sha256: 11deeae8d469cf41e243a044059dc1d8cbd7db3807f34166ead1dcc01ecb52c3

Contents?: true

Size: 809 Bytes

Versions: 5

Compression:

Stored size: 809 Bytes

Contents

# typed: true
module Parlour
  # The RBI generator.
  class RbiGenerator < Generator
    # For backwards compatibility.
    # Before Parlour 5.0, Parlour::Options was Parlour::RbiGenerator::Options.
    Options = Parlour::Options

    def initialize(**hash)
      super
      @root = RbiGenerator::Namespace.new(self)
    end

    sig { overridable.returns(RbiGenerator::Namespace) }
    # The root {Namespace} of this generator.
    # @return [Namespace]
    attr_reader :root

    sig { overridable.params(strictness: String).returns(String) }
    # Returns the complete contents of the generated RBI file as a string.
    #
    # @return [String] The generated RBI file
    def rbi(strictness = 'strong')
      "# typed: #{strictness}\n" + root.generate_rbi(0, options).join("\n") + "\n"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
parlour-9.1.0 lib/parlour/rbi_generator.rb
parlour-9.0.0 lib/parlour/rbi_generator.rb
parlour-8.1.0 lib/parlour/rbi_generator.rb
parlour-8.0.0 lib/parlour/rbi_generator.rb
parlour-7.0.0 lib/parlour/rbi_generator.rb