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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
//! Convenience wrapper for tree-sitter symbol node type enums across multiple languages.
//!
//! `tss` provides a unified interface for working with tree-sitter node types from multiple
//! language grammars. Rather than importing language-specific crates directly, you can enable
//! languages through features and access them through this single crate.
//!
//! # Quick Start
//!
//! ```toml
//! [dependencies]
//! tss = { version = "0.2", features = ["lang-rust-full"] }
//! tree-sitter = "0.24"
//! tree-sitter-rust = "0.24"
//! ```
//!
//! ```
//! # #[cfg(feature = "lang-rust-full")]
//! # {
//! use tree_sitter_symbols::NodeTypeRust;
//! use std::str::FromStr;
//!
//! let node_type = NodeTypeRust::from_str("function_item")?;
//! assert_eq!(node_type, NodeTypeRust::FunctionItem);
//! assert_eq!(node_type.to_string(), "function_item");
//! # }
//! # Ok::<(), String>(())
//! ```
//!
//! # Language-Specific Type Names
//!
//! Each language's `NodeType` is re-exported with the language name in `PascalCase`:
//!
//! - **Rust**: `tree_sitter_symbols_rust::NodeType` → `NodeTypeRust`
//! - **Python** (future): `tree_sitter_symbols_python::NodeType` → `NodeTypePython`
//!
//! This naming convention prevents confusion when working with multiple language grammars
//! simultaneously. You always know which language a node type belongs to.
//!
//! # Features
//!
//! **By default, this crate has no features enabled and provides no functionality.** You must
//! explicitly enable the languages you need.
//!
//! ## Language Selection
//!
//! Enable languages individually or all at once:
//!
//! ```toml
//! # Single language with metadata only (no node types)
//! tss = { version = "0.2", features = ["lang-rust"] }
//!
//! # All languages with metadata only (currently just Rust)
//! tss = { version = "0.2", features = ["lang-all"] }
//!
//! # All languages with full node types (currently just Rust)
//! tss = { version = "0.2", features = ["lang-all-full"] }
//! ```
//!
//! ## Language Variants: Metadata-Only vs. Full
//!
//! Each language has two feature variants:
//!
//! ### `lang-{name}` - Metadata Only
//!
//! Enables the language crate with `meta_full` but **no node types**. The `NodeType` enum
//! exists but has no variants, making it essentially unusable for pattern matching. This is
//! useful if you only need the metadata features or plan to enable specific node types manually.
//!
//! ```toml
//! # Rust with metadata only - NodeType enum exists but is empty
//! tss = { version = "0.2", features = ["lang-rust"] }
//! ```
//!
//! ### `lang-{name}-full` - Complete Functionality
//!
//! Enables the language crate with the `full` feature, which includes both `meta_full` and
//! `node_full`. This gives you all node types and all metadata - complete functionality.
//!
//! ```toml
//! # Rust with all node types + all metadata
//! tss = { version = "0.2", features = ["lang-rust-full"] }
//! ```
//!
//! ### Aggregate Features
//!
//! - **`lang-all`**: Enables all languages with metadata only (no node types)
//! - **`lang-all-full`**: Enables all languages with full functionality (all nodes + metadata)
//!
//! ```toml
//! # All languages, metadata only
//! tss = { version = "0.2", features = ["lang-all"] }
//!
//! # All languages, complete functionality
//! tss = { version = "0.2", features = ["lang-all-full"] }
//! ```
//!
//! ## Combining with Language Crate Features
//!
//! For fine-grained control, enable `tss` with a metadata-only language, then add the underlying
//! language crate with specific node type features:
//!
//! ```toml
//! [dependencies]
//! tss = { version = "0.2", features = ["lang-rust"] }
//! tss-rust = { version = "0.2", features = [
//! "function_item",
//! "struct_item",
//! "impl_item"
//! ]}
//! ```
//!
//! This gives you `NodeTypeRust` through `tss` with only the specific node types you need,
//! plus all metadata from the `lang-rust` feature.
//!
//! # When to Use This Crate
//!
//! **Use `tss`** when:
//! - You're working with multiple tree-sitter languages
//! - You want a unified import for all language support
//! - You prefer explicit type names like `NodeTypeRust` vs. `NodeType`
//! - You want `lang-all` or `lang-all-full` to easily enable all supported languages
//!
//! **Use language crates directly** (e.g., `tss-rust`) when:
//! - You're only working with a single language
//! - You want minimal dependencies
//! - You prefer the simpler `NodeType` name
//! - You need fine-grained control over individual node type features
//!
//! # How It Works
//!
//! This crate is a thin wrapper that re-exports the underlying language crates based on
//! enabled features. It adds zero runtime overhead - the re-exports are resolved at compile
//! time and generate identical code to using the language crates directly.
//!
//! Each language crate (`tss-rust`, etc.) generates node type enums at build time from the
//! corresponding `tree-sitter-*` crate's `NODE_TYPES` constant. See the individual language
//! crate documentation for details on code generation and available metadata features.
//!
//! # Available Languages
//!
//! Currently supported:
//! - **Rust** (`lang-rust`, `lang-rust-full`)
//!
//! Coming soon:
//! - **Python** (`lang-python`, `lang-python-full`)
//!
//! Additional languages will be added based on community demand.
/// Re-export of the complete `tree_sitter_symbols_rust` module.
///
/// Provides access to all types and functions from the Rust language crate.
/// Use this when you need the full module API, or prefer to access `NodeType`
/// through the module path.
///
/// # Examples
///
/// ```
/// # #[cfg(feature = "lang-rust")]
/// # {
/// use tree_sitter_symbols::tree_sitter_symbols_rust;
///
/// // Access through the module
/// let node_type = tree_sitter_symbols_rust::NodeType::FunctionItem;
/// # }
/// ```
pub use tree_sitter_symbols_rust;
/// Rust language node type enum.
///
/// This is a re-export of `tree_sitter_symbols_rust::NodeType` with a language-specific
/// name to avoid confusion when working with multiple languages.
///
/// # Examples
///
/// ```
/// # #[cfg(all(feature = "lang-rust-full"))]
/// # {
/// use tree_sitter_symbols::NodeTypeRust;
/// use std::str::FromStr;
///
/// let node_type = NodeTypeRust::from_str("function_item")?;
/// assert_eq!(node_type, NodeTypeRust::FunctionItem);
/// # }
/// # Ok::<(), String>(())
/// ```
///
/// See the [`tree_sitter_symbols_rust`] module documentation for details on available
/// features and metadata.
pub use NodeType as NodeTypeRust;