aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md23
1 files changed, 17 insertions, 6 deletions
diff --git a/README.md b/README.md
index 74e99ce..bfc91a9 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ macros.
quote = "1.0"
```
-*Version requirement: Quote supports rustc 1.31 and up.*<br>
+*Version requirement: Quote supports rustc 1.56 and up.*<br>
[*Release notes*](https://github.com/dtolnay/quote/releases)
<br>
@@ -233,15 +233,26 @@ macro.
## Non-macro code generators
When using `quote` in a build.rs or main.rs and writing the output out to a
-file, consider having the code generator pass the tokens through [rustfmt]
-before writing (either by shelling out to the `rustfmt` binary or by pulling in
-the `rustfmt` library as a dependency). This way if an error occurs in the
-generated code it is convenient for a human to read and debug.
+file, consider having the code generator pass the tokens through [prettyplease]
+before writing. This way if an error occurs in the generated code it is
+convenient for a human to read and debug.
Be aware that no kind of hygiene or span information is retained when tokens are
written to a file; the conversion from tokens to source code is lossy.
-[rustfmt]: https://github.com/rust-lang/rustfmt
+Example usage in build.rs:
+
+```rust
+let output = quote! { ... };
+let syntax_tree = syn::parse2(output).unwrap();
+let formatted = prettyplease::unparse(&syntax_tree);
+
+let out_dir = env::var_os("OUT_DIR").unwrap();
+let dest_path = Path::new(&out_dir).join("out.rs");
+fs::write(dest_path, formatted).unwrap();
+```
+
+[prettyplease]: https://github.com/dtolnay/prettyplease
<br>