Skip to content

Commit 4e83a52

Browse files
committed
Documentation
1 parent 1dbde78 commit 4e83a52

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

README.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
[![Build Status](https://github.com/kddnewton/syntax_tree/workflows/Main/badge.svg)](https://github.com/kddnewton/syntax_tree/actions)
44
[![Gem Version](https://img.shields.io/gem/v/syntax_tree.svg)](https://rubygems.org/gems/syntax_tree)
55

6-
A fast ripper subclass used for generating syntax trees from Ruby code.
6+
A fast ripper subclass used for parsing and formatting Ruby code.
77

88
## Installation
99

1010
Add this line to your application's Gemfile:
1111

1212
```ruby
13-
gem 'syntax_tree'
13+
gem "syntax_tree"
1414
```
1515

1616
And then execute:
@@ -26,25 +26,29 @@ Or install it yourself as:
2626
From code:
2727

2828
```ruby
29-
require 'syntax_tree'
29+
require "syntax_tree"
3030

31-
parser = SyntaxTree.new(source)
32-
33-
node = parser.parse
34-
raise if parser.error?
35-
36-
pp node
31+
pp SyntaxTree.parse(source) # print out the AST
32+
puts SyntaxTree.format(source) # format the AST
3733
```
3834

3935
From the CLI:
4036

4137
```sh
42-
$ stree program.rb
38+
$ stree ast program.rb
4339
(program
4440
(statements
4541
...
4642
```
4743
44+
or
45+
46+
```sh
47+
$ stree format program.rb
48+
class MyClass
49+
...
50+
```
51+
4852
## Development
4953
5054
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

0 commit comments

Comments
 (0)