macro_tools/
lib.rs

1#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ]
2#![ doc
3(
4  html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico"
5) ]
6#![ doc( html_root_url = "https://docs.rs/proc_macro_tools/latest/proc_macro_tools/" ) ]
7#![ cfg_attr( doc, doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "readme.md" ) ) ) ]
8#![ cfg_attr( not( doc ), doc = "Macro utilities" ) ]
9
10//! # Rule Compliance & Architectural Notes
11//!
12//! This crate provides macro utilities and has been systematically updated to comply
13//! with the Design and Codestyle Rulebooks.
14//!
15//! ## Completed Compliance Work:
16//!
17//! 1. **Feature Architecture**: All functionality is properly gated behind the "enabled" feature.
18//!
19//! 2. **Documentation Strategy**: Uses `#![ doc = include_str!(...) ]` to include readme.md
20//!    instead of duplicating documentation in source files.
21//!
22//! 3. **Attribute Formatting**: All attributes use proper spacing per Universal Formatting Rule.
23//!
24//! 4. **Dependencies**: This crate provides the `macro_tools` abstractions that other crates
25//!    should use instead of direct `syn`, `quote`, `proc-macro2` dependencies.
26
27/// Define a private namespace for all its items.
28#[ cfg( feature = "enabled" ) ]
29mod private
30{
31  use crate::*;
32
33  /// Result with `syn::Error`.
34  pub type Result< T > = core::result::Result< T, syn::Error >;
35}
36
37#[ cfg(all(feature = "enabled", feature = "attr")) ]
38pub mod attr;
39#[ cfg(all(feature = "enabled", feature = "attr_prop")) ]
40pub mod attr_prop;
41#[ cfg(all(feature = "enabled", feature = "components")) ]
42pub mod components;
43#[ cfg(all(feature = "enabled", feature = "container_kind")) ]
44pub mod container_kind;
45#[ cfg(all(feature = "enabled", feature = "ct")) ]
46pub mod ct;
47#[ cfg(all(feature = "enabled", feature = "derive")) ]
48pub mod derive;
49#[ cfg(all(feature = "enabled", feature = "diag")) ]
50pub mod diag;
51#[ cfg(all(feature = "enabled", feature = "equation")) ]
52pub mod equation;
53#[ cfg(all(feature = "enabled", feature = "generic_args")) ]
54pub mod generic_args;
55#[ cfg(all(feature = "enabled", feature = "generic_params")) ]
56pub mod generic_params;
57#[ cfg(all(feature = "enabled", feature = "ident")) ] // Use new feature name
58pub mod ident; // Use new module name
59#[ cfg(all(feature = "enabled", feature = "item")) ]
60pub mod item;
61#[ cfg(all(feature = "enabled", feature = "item_struct")) ]
62pub mod item_struct;
63#[ cfg(all(feature = "enabled", feature = "kw")) ]
64pub mod kw;
65#[ cfg(all(feature = "enabled", feature = "name")) ]
66pub mod name;
67#[ cfg(all(feature = "enabled", feature = "phantom")) ]
68pub mod phantom;
69#[ cfg(all(feature = "enabled", feature = "punctuated")) ]
70pub mod punctuated;
71#[ cfg(all(feature = "enabled", feature = "quantifier")) ]
72pub mod quantifier;
73#[ cfg(all(feature = "enabled", feature = "struct_like")) ]
74pub mod struct_like;
75#[ cfg(all(feature = "enabled", feature = "tokens")) ]
76pub mod tokens;
77#[ cfg(all(feature = "enabled", feature = "typ")) ]
78pub mod typ;
79#[ cfg(all(feature = "enabled", feature = "typed")) ]
80pub mod typed;
81
82#[ cfg( feature = "enabled" ) ]
83pub mod iter;
84
85///
86/// Dependencies of the module.
87///
88#[ cfg( feature = "enabled" ) ]
89#[ allow( unused_imports ) ]
90pub mod dependency
91{
92  pub use ::syn;
93  pub use ::quote;
94  pub use ::proc_macro2;
95  pub use ::interval_adapter;
96  pub use ::clone_dyn_types;
97  pub use ::component_model_types;
98}
99
100#[ doc( inline ) ]
101#[ allow( unused_imports ) ]
102#[ cfg( feature = "enabled" ) ]
103pub use own::*;
104
105// qqq: put every file of the first level under feature
106
107/// Own namespace of the module.
108#[ cfg( feature = "enabled" ) ]
109#[ allow( unused_imports ) ]
110pub mod own
111{
112  // use super::*;
113
114  mod _all
115  {
116
117  use super::super::*;
118  pub use orphan::*;
119
120  pub use prelude::syn;
121  pub use prelude::proc_macro2;
122  pub use prelude::quote;
123
124  pub use private::{ Result };
125
126  #[ cfg( feature = "attr" ) ]
127  pub use attr::orphan::*;
128  #[ cfg( feature = "attr_prop" ) ]
129  pub use attr_prop::orphan::*;
130  #[ cfg( feature = "components" ) ]
131  pub use components::orphan::*;
132  #[ cfg( feature = "container_kind" ) ]
133  pub use container_kind::orphan::*;
134  #[ cfg( feature = "ct" ) ]
135  pub use ct::orphan::*;
136  #[ cfg( feature = "derive" ) ]
137  pub use derive::orphan::*;
138  #[ cfg( feature = "diag" ) ]
139  pub use diag::orphan::*;
140  #[ cfg( feature = "equation" ) ]
141  pub use equation::orphan::*;
142  #[ cfg( feature = "generic_args" ) ]
143  pub use generic_args::orphan::*;
144  #[ cfg( feature = "generic_params" ) ]
145  pub use generic_params::orphan::*;
146  #[ cfg( feature = "ident" ) ] // Use new feature name
147  pub use ident::orphan::*; // Use new module name
148  #[ cfg( feature = "item" ) ]
149  pub use item::orphan::*;
150  #[ cfg( feature = "item_struct" ) ]
151  pub use item_struct::orphan::*;
152  #[ cfg( feature = "name" ) ]
153  pub use name::orphan::*;
154  #[ cfg( feature = "kw" ) ]
155  pub use kw::orphan::*;
156  #[ cfg( feature = "phantom" ) ]
157  pub use phantom::orphan::*;
158  #[ cfg( feature = "punctuated" ) ]
159  pub use punctuated::orphan::*;
160  #[ cfg( feature = "quantifier" ) ]
161  pub use quantifier::orphan::*;
162  #[ cfg( feature = "struct_like" ) ]
163  pub use struct_like::orphan::*;
164  #[ cfg( feature = "tokens" ) ]
165  pub use tokens::orphan::*;
166  #[ cfg( feature = "typ" ) ]
167  pub use typ::orphan::*;
168  #[ cfg( feature = "typed" ) ]
169  pub use typed::orphan::*;
170
171  pub use iter::orphan::*;
172 }
173
174  #[ doc( inline ) ]
175  pub use _all::*;
176}
177
178/// Parented namespace of the module.
179#[ cfg( feature = "enabled" ) ]
180#[ allow( unused_imports ) ]
181pub mod orphan
182{
183  use super::*;
184
185  mod _all
186  {
187
188  use super::super::*;
189  pub use exposed::*;
190 }
191
192  #[ doc( inline ) ]
193  pub use _all::*;
194}
195
196/// Exposed namespace of the module.
197#[ cfg( feature = "enabled" ) ]
198#[ allow( unused_imports ) ]
199pub mod exposed
200{
201  use super::*;
202
203  mod _all
204  {
205
206  use super::super::*;
207  pub use prelude::*;
208
209  #[ cfg( feature = "attr" ) ]
210  pub use attr::exposed::*;
211  #[ cfg( feature = "attr_prop" ) ]
212  pub use attr_prop::exposed::*;
213  #[ cfg( feature = "components" ) ]
214  pub use components::exposed::*;
215  #[ cfg( feature = "container_kind" ) ]
216  pub use container_kind::exposed::*;
217  #[ cfg( feature = "ct" ) ]
218  pub use ct::exposed::*;
219  #[ cfg( feature = "derive" ) ]
220  pub use derive::exposed::*;
221  #[ cfg( feature = "diag" ) ]
222  pub use diag::exposed::*;
223  #[ cfg( feature = "equation" ) ]
224  pub use equation::exposed::*;
225  #[ cfg( feature = "generic_args" ) ]
226  pub use generic_args::exposed::*;
227  #[ cfg( feature = "generic_params" ) ]
228  pub use generic_params::exposed::*;
229  #[ cfg( feature = "ident" ) ] // Use new feature name
230  pub use ident::exposed::*; // Use new module name
231  #[ cfg( feature = "item" ) ]
232  pub use item::exposed::*;
233  #[ cfg( feature = "item_struct" ) ]
234  pub use item_struct::exposed::*;
235  #[ cfg( feature = "name" ) ]
236  pub use name::exposed::*;
237  #[ cfg( feature = "kw" ) ]
238  pub use kw::exposed::*;
239  #[ cfg( feature = "phantom" ) ]
240  pub use phantom::exposed::*;
241  #[ cfg( feature = "punctuated" ) ]
242  pub use punctuated::exposed::*;
243  #[ cfg( feature = "quantifier" ) ]
244  pub use quantifier::exposed::*;
245  #[ cfg( feature = "struct_like" ) ]
246  pub use struct_like::exposed::*;
247  #[ cfg( feature = "tokens" ) ]
248  pub use tokens::exposed::*;
249  #[ cfg( feature = "typ" ) ]
250  pub use typ::exposed::*;
251  #[ cfg( feature = "typed" ) ]
252  pub use typed::exposed::*;
253
254  pub use iter::exposed::*;
255 }
256
257  #[ doc( inline ) ]
258  pub use _all::*;
259}
260
261/// Prelude to use essentials: `use my_module::prelude::*`.
262#[ cfg( feature = "enabled" ) ]
263#[ allow( unused_imports ) ]
264pub mod prelude
265{
266  use super::*;
267
268  mod _all
269  {
270
271  use super::super::*;
272  // pub use prelude :: *;
273
274  #[ cfg( feature = "attr" ) ]
275  pub use attr::prelude::*;
276  #[ cfg( feature = "attr_prop" ) ]
277  pub use attr_prop::prelude::*;
278  #[ cfg( feature = "components" ) ]
279  pub use components::prelude::*;
280  #[ cfg( feature = "container_kind" ) ]
281  pub use container_kind::prelude::*;
282  #[ cfg( feature = "ct" ) ]
283  pub use ct::prelude::*;
284  #[ cfg( feature = "derive" ) ]
285  pub use derive::prelude::*;
286  #[ cfg( feature = "diag" ) ]
287  pub use diag::prelude::*;
288  #[ cfg( feature = "equation" ) ]
289  pub use equation::prelude::*;
290  #[ cfg( feature = "generic_args" ) ]
291  pub use generic_args::prelude::*;
292  #[ cfg( feature = "generic_params" ) ]
293  pub use generic_params::prelude::*;
294  #[ cfg( feature = "ident" ) ] // Use new feature name
295  pub use ident::prelude::*; // Use new module name
296  #[ cfg( feature = "item" ) ]
297  pub use item::prelude::*;
298  #[ cfg( feature = "item_struct" ) ]
299  pub use item_struct::prelude::*;
300  #[ cfg( feature = "name" ) ]
301  pub use name::prelude::*;
302  #[ cfg( feature = "kw" ) ]
303  pub use kw::exposed::*;
304  #[ cfg( feature = "phantom" ) ]
305  pub use phantom::prelude::*;
306  #[ cfg( feature = "punctuated" ) ]
307  pub use punctuated::prelude::*;
308  #[ cfg( feature = "quantifier" ) ]
309  pub use quantifier::prelude::*;
310  #[ cfg( feature = "struct_like" ) ]
311  pub use struct_like::prelude::*;
312  #[ cfg( feature = "tokens" ) ]
313  pub use tokens::prelude::*;
314  #[ cfg( feature = "typ" ) ]
315  pub use typ::prelude::*;
316  #[ cfg( feature = "typed" ) ]
317  pub use typed::prelude::*;
318
319  pub use iter::prelude::*;
320 }
321
322  #[ doc( inline ) ]
323  pub use _all::*;
324
325  #[ doc( inline ) ]
326  pub use ::interval_adapter::prelude::*;
327
328  #[ doc( inline ) ]
329  pub use ::syn;
330
331  #[ doc( inline ) ]
332  #[ allow( unused_imports ) ]
333  pub use ::proc_macro2;
334
335  #[ doc( inline ) ]
336  #[ allow( unused_imports ) ]
337  pub use ::quote;
338
339  #[ doc( inline ) ]
340  #[ allow( unused_imports ) ]
341  pub use ::quote::{ quote, quote as qt, quote_spanned, format_ident };
342
343  // #[ doc( inline ) ]
344  // #[ allow( unused_imports ) ]
345  // pub use ::syn::spanned::Spanned;
346
347  #[ doc( inline ) ]
348  #[ allow( unused_imports ) ]
349  pub use syn::{
350  parse::ParseStream, Token, spanned::Spanned, braced, bracketed, custom_keyword, custom_punctuation, parenthesized,
351  parse_macro_input, parse_quote, parse_quote as parse_qt, parse_quote_spanned, parse_quote_spanned as parse_qt_spanned,
352 };
353}