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
//! genco is a code generator and quasi quoter for Rust, written for use in
//! [reproto].
//!
//! The workhorse of genco is the [quote!] and [quote_in!] macros. While tokens
//! can be constructed manually, these make this process much easier.
//!
//! genco only minimally deals with language-specific syntax, but primarily deals
//! with solving the following:
//!
//! * **Imports** — genco generates and groups import statements according to
//! conventions for the language being generated for.
//!
//! * **String Quoting** — Strings can be quoted using the [`<stmt>.quoted()`]
//! trait function.
//!
//! * **Structural Indentation** — genco's quasi quoting utilizes
//! [whitespace detection] to structurally sort out spaces and indentation.
//!
//! <br>
//!
//! We depend on `proc_macro_hygiene` stabilizations. Until then, you must build
//! and run with the `nightly` branch.
//!
//! ```bash
//! cargo +nightly run --example rust
//! ```
//!
//! <br>
//!
//! ## Examples
//!
//! The following are language specific examples for genco using the [quote!]
//! macro.
//!
//! * [Rust Example]
//! * [Java Example]
//! * [C# Example]
//! * [Go Example]
//! * [Dart Example]
//! * [JavaScript Example]
//! * [Python Example]
//!
//! You can run one of the examples above using:
//!
//! ```bash
//! cargo run --example go
//! ```
//!
//! <br>
//!
//! ## Rust Example
//!
//! The following is a simple program producing Rust code to stdout with custom
//! configuration:
//!
//! ```rust,no_run
//! use genco::prelude::*;
//! use genco::fmt;
//!
//! # fn main() -> fmt::Result {
//! let map = rust::imported("std::collections", "HashMap");
//!
//! let tokens: rust::Tokens = quote! {
//! fn main() {
//! let mut m = #map::new();
//! m.insert(1u32, 2u32);
//! }
//! };
//!
//! let stdout = std::io::stdout();
//! let mut w = fmt::IoWriter::new(stdout.lock());
//!
//! let fmt = fmt::Config::from_lang::<Rust>().with_indentation(2);
//! let config = rust::Config::default();
//!
//! tokens.format_file(&mut w.as_formatter(fmt), &config)?;
//! # Ok(())
//! # }
//! ```
//!
//! This would produce:
//!
//! ```rust,no_run
//! use std::collections::HashMap;
//!
//! fn main() {
//! let mut m = HashMap::new();
//! m.insert(1u32, 2u32);
//! }
//! ```
//!
//! <br>
//!
//! [reproto]: https://github.com/reproto/reproto
//! [whitespace detection]: https://docs.rs/genco/0/genco/macro.quote.html#whitespace-detection
//! [Rust Example]: https://github.com/udoprog/genco/blob/master/examples/rust.rs
//! [Java Example]: https://github.com/udoprog/genco/blob/master/examples/java.rs
//! [C# Example]: https://github.com/udoprog/genco/blob/master/examples/csharp.rs
//! [Go Example]: https://github.com/udoprog/genco/blob/master/examples/go.rs
//! [Dart Example]: https://github.com/udoprog/genco/blob/master/examples/dart.rs
//! [JavaScript Example]: https://github.com/udoprog/genco/blob/master/examples/js.rs
//! [Python Example]: https://github.com/udoprog/genco/blob/master/examples/python.rs
//! [quote!]: https://docs.rs/genco/0/genco/macro.quote.html
//! [quote_in!]: https://docs.rs/genco/0/genco/macro.quote_in.html
//! [`<stmt>.quoted()`]: https://docs.rs/genco/0/genco/trait.QuotedExt.html
pub use ;
/// Prelude to import.
pub use ;
pub use FormatTokens;
pub use Item;
pub use ItemStr;
pub use *;
pub use RegisterTokens;
pub use Tokens;