1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//! Generated node type enums and metadata from tree-sitter-rust.
//!
//! `tss-rust` provides type-safe Rust enums for every node type in the tree-sitter-rust grammar.
//! This eliminates error-prone string comparisons like `node.kind() == "function_item"` in favor
//! of `NodeType::FunctionItem`, enabling compile-time verification and better IDE support.
//!
//! # Quick Start
//!
//! ```toml
//! [dependencies]
//! tss-rust = "0.2"
//! tree-sitter = "0.24"
//! tree-sitter-rust = "0.24"
//! ```
//!
//! ```
//! use tree_sitter_symbols_rust::NodeType;
//! use std::str::FromStr;
//!
//! let node_type = NodeType::from_str("function_item")?;
//! assert_eq!(node_type, NodeType::FunctionItem);
//! assert_eq!(node_type.to_string(), "function_item");
//! # Ok::<(), String>(())
//! ```
//!
//! # Features
//!
//! **By default, this crate has no features enabled.** You must explicitly enable the node types
//! and metadata you need. This keeps compile times fast and binary sizes small.
//!
//! The crate uses Cargo features to control which node types and metadata are available:
//!
//! ## Node Type Features
//!
//! Each tree-sitter node type corresponds to a feature. Enable specific nodes:
//!
//! ```toml
//! tss-rust = { version = "0.2", features = ["function_item", "struct_item"] }
//! ```
//!
//! Or enable all node types at once:
//!
//! ```toml
//! tss-rust = { version = "0.2", features = ["node_full"] }
//! ```
//!
//! The `node` feature is a tracking feature automatically enabled when any node type is active.
//! You don't need to enable it manually - it's used internally for conditional compilation.
//!
//! ## Metadata Features
//!
//! Control which metadata from tree-sitter's `NODE_TYPES` JSON is included:
//!
//! - `meta_named` - whether nodes are named in the grammar
//! - `meta_subtypes` - possible subtypes for each node
//! - `meta_fields` - named fields nodes can have
//! - `meta_children` - anonymous children nodes can have
//! - `meta_extra` - extra node markers
//! - `meta_root` - root node markers
//!
//! Enable all metadata:
//!
//! ```toml
//! tss-rust = { version = "0.2", features = ["meta_full"] }
//! ```
//!
//! Or select specific metadata categories:
//!
//! ```toml
//! tss-rust = { version = "0.2", features = ["meta_named", "meta_fields"] }
//! ```
//!
//! The `meta` feature is a tracking feature automatically enabled when any metadata feature is active.
//! You don't need to enable it manually - it's used internally for conditional compilation.
//!
//! ## Complete Feature Matrix
//!
//! ```toml
//! # Default: empty - no features enabled
//! tss-rust = "0.2"
//!
//! # Everything: all nodes + all metadata
//! tss-rust = { version = "0.2", features = ["full"] }
//!
//! # Just nodes, no metadata
//! tss-rust = { version = "0.2", features = ["node_full"] }
//!
//! # Just metadata, no nodes
//! tss-rust = { version = "0.2", features = ["meta_full"] }
//!
//! # Specific nodes with selected metadata
//! tss-rust = { version = "0.2", features = [
//! "function_item",
//! "struct_item",
//! "meta_named"
//! ]}
//! ```
//!
//! # How It Works
//!
//! At build time, `tss-rust` reads the `NODE_TYPES` constant from the `tree-sitter-rust` crate
//! and generates:
//!
//! - A `NodeType` enum with variants for all 280+ node types
//! - `FromStr` implementation for parsing node type strings
//! - `Display` implementation for converting back to strings
//! - Documentation linking to Rust language reference where applicable
//! - Feature-gated compilation so you only pay for what you use
//!
//! All generation happens at compile time with zero runtime dependencies. The generated code
//! is feature-gated, so with no features enabled, the crate compiles to almost nothing.
//!
//! # Design Philosophy
//!
//! **Type Safety**: String comparisons are error-prone and not checked at compile time. Using
//! enum variants catches typos early and enables exhaustive pattern matching.
//!
//! **Minimal Overhead**: With no default features, you explicitly choose what to include. Add
//! only the node types you actually use in your tree-sitter traversals.
//!
//! **Build-Time Generation**: By generating at build time rather than using macros, we get
//! better IDE support, faster compile times, and the ability to inspect generated code.
// The generated code is included from the build script output
include!;