Module: SyntaxTree::RBS

Defined in:
lib/syntax_tree/rbs.rb,
lib/syntax_tree/rbs/format.rb,
lib/syntax_tree/rbs/version.rb,
lib/syntax_tree/rbs/entrypoints.rb,
lib/syntax_tree/rbs/pretty_print.rb

Defined Under Namespace

Modules: Entrypoints Classes: Format, Formatter, PrettyPrint, Root, Visitor

Constant Summary collapse

VERSION =
"0.5.0"

Class Method Summary collapse

Class Method Details

.format(source, maxwidth = 80) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/syntax_tree/rbs.rb', line 47

def format(source, maxwidth = 80)
  formatter = Formatter.new(source, [], maxwidth)
  parse(source).format(formatter)

  formatter.flush
  formatter.output.join
end

.parse(source) ⇒ Object



55
56
57
# File 'lib/syntax_tree/rbs.rb', line 55

def parse(source)
  Root.new(::RBS::Parser.parse_signature(source))
end

.read(filepath) ⇒ Object



59
60
61
# File 'lib/syntax_tree/rbs.rb', line 59

def read(filepath)
  File.read(filepath)
end