treesitter_types_ruby/lib.rs
1//! Strongly-typed AST types for Ruby, auto-generated from
2//! [`tree-sitter-ruby`](https://docs.rs/tree-sitter-ruby)'s `node-types.json`.
3//!
4//! This crate is generated by [`treesitter-types`](https://docs.rs/treesitter-types) and is
5//! automatically kept up to date when a new version of the grammar crate is released.
6//!
7//! These types have been tested by parsing the
8//! [Rails](https://github.com/rails/rails) source code.
9//!
10//! See the [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) project for more
11//! information about the underlying parser framework.
12//!
13//! # Example
14//!
15//! ```
16//! use treesitter_types_ruby::*;
17//!
18//! // A minimal Ruby hello-world program.
19//! let src = b"\
20//! def greet(name)
21//! puts \"Hello, #{name}!\"
22//! end
23//!
24//! greet(\"World\")
25//! ";
26//!
27//! // Parse the source with tree-sitter and convert into typed AST.
28//! let mut parser = tree_sitter::Parser::new();
29//! parser.set_language(&tree_sitter_ruby::LANGUAGE.into()).unwrap();
30//! let tree = parser.parse(src, None).unwrap();
31//! let program = Program::from_node(tree.root_node(), src).unwrap();
32//!
33//! // The program has two top-level children:
34//! // a method definition and a method call.
35//! assert_eq!(program.children.len(), 2);
36//!
37//! // Both statements start at column 0.
38//! assert_eq!(program.span.start.row, 0);
39//! assert_eq!(program.span.start.column, 0);
40//! assert!(program.span.end.row >= 4);
41//! ```
42
43pub use treesitter_types::{FromNode, LeafNode, ParseError, Span, Spanned};
44
45mod generated;
46pub use generated::*;