blob: 1860211f89bc92509ea205c6219ca9c0cc13e477 [file] [log] [blame]
David Tolnay4b4c4b62018-01-06 13:48:05 -08001//! This crate automatically generates the definition of the `Visit`,
2//! `VisitMut`, and `Fold` traits in `syn` based on the `syn` source. It
Nika Layzell27726662017-10-24 23:16:35 -04003//! discovers structs and enums declared with the `ast_*` macros and generates
4//! the functions for those types.
5//!
6//! It makes a few assumptions about the target crate:
7//! 1. All structs which are discovered must be re-exported in the root of the
8//! crate, even if they were declared in a submodule.
9//! 2. This code cannot discover submodules which are located in subdirectories
10//! - only submodules located in the same directory.
11//! 3. The path to `syn` is hardcoded.
12
David Tolnay6af48992018-08-01 11:16:28 -070013#![recursion_limit = "128"]
David Tolnayc1f55792018-11-21 01:39:42 -080014#![allow(clippy::needless_pass_by_value)]
David Tolnayea9ae892017-12-26 01:44:32 -050015
Nika Layzell27726662017-10-24 23:16:35 -040016extern crate inflections;
David Tolnay2e0dba12017-12-27 01:54:40 -050017extern crate proc_macro2;
David Tolnayd67fb752017-12-27 13:50:29 -050018#[macro_use]
19extern crate quote;
David Tolnay8c81f622018-07-31 23:34:35 -070020extern crate rustfmt_nightly as rustfmt;
Carl Lerche058ff472019-02-13 16:23:52 -080021#[macro_use]
David Tolnay5f794802018-11-24 14:51:21 -080022extern crate syn;
Carl Lerche9a7d5882019-02-15 12:27:04 -080023extern crate serde;
24#[macro_use]
25extern crate serde_derive;
26extern crate serde_json;
27extern crate toml;
Nika Layzell27726662017-10-24 23:16:35 -040028
Carl Lerche058ff472019-02-13 16:23:52 -080029mod gen;
Carl Lerche9a7d5882019-02-15 12:27:04 -080030mod json;
Carl Lerche058ff472019-02-13 16:23:52 -080031mod parse;
32mod types;
David Tolnay8c81f622018-07-31 23:34:35 -070033
Nika Layzell27726662017-10-24 23:16:35 -040034fn main() {
Carl Lerche058ff472019-02-13 16:23:52 -080035 let types = parse::parse();
36 gen::generate(&types);
Carl Lerche9a7d5882019-02-15 12:27:04 -080037 json::generate(&types);
Nika Layzell27726662017-10-24 23:16:35 -040038}