procout

This depends on the procedural macro compiling to code. If it's not at the stage where it compiles, it has to get there before this will produce useful output.

Whereby

Given a procedural macro's constructed as so,

```rust use procmacro::{TokenStream}; use procmacro2::{Span}; use quote::{quote}; use syn::{Ident};

[proc_macro]

pub fn ast(input: TokenStream) -> TokenStream { let moduleident = Ident::new("thismodule", Span::mixedsite()); let codeblock: procmacro2::TokenStream = quote!{ pub mod #moduleident { /* ... some truly fantastic code, well done ... */ } }; // Convert and return the code TokenStream::from(code_block) } ``` Just insert a call to procout before the conversion and return step.

```rust use procmacro::{TokenStream}; use procmacro2::{Span}; use procout::{procout}; // Look! use quote::{quote}; use syn::{Ident};

[proc_macro]

pub fn ast(input: TokenStream) -> TokenStream { let moduleident = Ident::new("thismodule", Span::mixedsite()); let codeblock: procmacro2::TokenStream = quote!{ pub mod #moduleident { /* ... some truly fantastic code, well done ... */ } };

// Look! procout(&codeblock, Some(moduleident), Some("a/valid/path/string"));

// Convert and return the code TokenStream::from(code_block) } ```

By calling cargo test --features procout, the code will print to the a/valid/path/string specified as a file corresponding to module_ident. By default, the path string is the local tests directory, so after the first run using the procout feature, it's possible to run something like cargo test --test module_ident and get better errors from the compiler.

Now with these splendid new capabilities:

Warning:

This will overwrite whatever's at the specified path, so be careful when prototyping.

Features

License: MIT