Class: Parlour::RbiGenerator

Inherits:
Generator show all
Defined in:
lib/parlour/rbi_generator.rb,
lib/parlour/rbi_generator/extend.rb,
lib/parlour/rbi_generator/method.rb,
lib/parlour/rbi_generator/include.rb,
lib/parlour/rbi_generator/constant.rb,
lib/parlour/rbi_generator/arbitrary.rb,
lib/parlour/rbi_generator/attribute.rb,
lib/parlour/rbi_generator/namespace.rb,
lib/parlour/rbi_generator/parameter.rb,
lib/parlour/rbi_generator/rbi_object.rb,
lib/parlour/rbi_generator/type_alias.rb,
lib/parlour/rbi_generator/struct_prop.rb,
lib/parlour/rbi_generator/class_namespace.rb,
lib/parlour/rbi_generator/module_namespace.rb,
lib/parlour/rbi_generator/enum_class_namespace.rb,
lib/parlour/rbi_generator/struct_class_namespace.rb

Overview

The RBI generator.

Direct Known Subclasses

DetachedRbiGenerator

Defined Under Namespace

Classes: Arbitrary, Attribute, ClassNamespace, Constant, EnumClassNamespace, Extend, Include, Method, ModuleNamespace, Namespace, Parameter, RbiObject, StructClassNamespace, StructProp, TypeAlias

Constant Summary collapse

Options =

For backwards compatibility. Before Parlour 5.0, Parlour::Options was Parlour::RbiGenerator::Options.

Parlour::Options

Instance Attribute Summary collapse

Attributes inherited from Generator

#current_plugin, #options

Instance Method Summary collapse

Constructor Details

#initialize(**hash) ⇒ RbiGenerator

Returns a new instance of RbiGenerator.



9
10
11
12
# File 'lib/parlour/rbi_generator.rb', line 9

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

Instance Attribute Details

#rootNamespace (readonly)

The root Namespace of this generator.

Returns:



17
18
19
# File 'lib/parlour/rbi_generator.rb', line 17

def root
  @root
end

Instance Method Details

#rbi(strictness = 'strong') ⇒ String

Returns the complete contents of the generated RBI file as a string.

Returns:

  • (String)

    The generated RBI file



23
24
25
# File 'lib/parlour/rbi_generator.rb', line 23

def rbi(strictness = 'strong')
  "# typed: #{strictness}\n" + root.generate_rbi(0, options).join("\n") + "\n"
end