Syntax Tree – Ruby formatter and syntax tree toolkit

Syntax Tree is a toolkit for parsing, inspecting, transforming and formatting Ruby source code. Rather than being limited to producing consistently styled source, it represents Ruby programs as syntax trees that other development tools can inspect and manipulate.

This wider scope makes Syntax Tree useful both as an end-user formatter and as infrastructure for programmers building source-code tooling. It exposes its functionality through a command-line interface and Ruby APIs, with facilities covering structural inspection, transformation, searching and editor integration.

This is free and open source software.

Key Features

  • Formats Ruby source from the command line with the stree format command.
  • Writes formatted output back to files with the stree write command.
  • Checks formatting without rewriting files, making it suitable for continuous integration and Git hooks.
  • Supports a configurable print width for formatting and checking.
  • Accepts file paths, standard input and inline Ruby source for many CLI operations.
  • Can ignore selected files when formatting globbed project paths.
  • Produces textual syntax-tree representations for inspection and debugging.
  • Exports parsed syntax trees as JSON for use by other tools.
  • Generates ctags-compatible output from Ruby source.
  • Provides pattern-based searching across parsed syntax nodes.
  • Can generate Ruby pattern-matching expressions from source constructs.
  • Exposes Ruby APIs for reading, parsing, formatting, searching, indexing and mutating source.
  • Includes visitor APIs for traversing and transforming syntax trees.
  • Provides a plugin system so additional languages and syntax-tree implementations can participate in the same tooling.
  • Includes language-server functionality such as document formatting and other source-aware editor features.
  • Can be incorporated into development tools that need structured access to Ruby syntax rather than text-only rewriting.

Website: github.com/ruby-syntax-tree/syntax_tree
Support:
Developer: Kevin Newton
License: MIT License

Syntax Tree is written in Ruby. Learn Ruby with our recommended free books and free tutorials.


Best Free and Open Source Software Explore our carefully curated directory of recommended free and open source software, covering every major software category.

The directory forms part of our extensive collection of articles for Linux enthusiasts. It includes hundreds of detailed reviews, together with free and open source alternatives to proprietary software from companies such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk.

LinuxLinks also covers interesting projects worth exploring, Linux-compatible hardware, free programming books and tutorials, and much more.

Know a useful free and open source Linux application that we haven’t covered? Tell us about it using our submission form.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted