Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dart all pushed in a single line #41

Closed
gnunicorn opened this issue Jun 16, 2023 · 3 comments
Closed

dart all pushed in a single line #41

gnunicorn opened this issue Jun 16, 2023 · 3 comments

Comments

@gnunicorn
Copy link

using genco 0.17.5 the default formatter for dart appears to be broken - it puts everything into a single line. Which in turn breaks dartc when having #[doc = in there.

Take this cargo-play example:

//# genco = "0.17.5"

use genco::prelude::*;

fn main() {
    // Some JSON input data as a &str. Maybe this comes from the user.
    let tokens: dart::Tokens = quote! {
        /// doc comment
        class Api {
            final String lateString;
        }
    };

    assert_eq!(tokens.to_file_vec().unwrap().len(), 4);
}

Rather than 4 lines, to_file_vec wraps it all into one :( .

My cargo: cargo 1.70.0 (ec8a8a0ca 2023-04-25) but nightly doesn't show anything different.

@udoprog
Copy link
Owner

udoprog commented Jun 16, 2023

See #39, which should hopefully be a temporary issue.

And as for the comment, it's expanded as a attribute before it's handed to the macro, so you have to do something like this for verbatim comments:

    let tokens: dart::Tokens = quote! {
        $("/// doc comment")
        class Api {
            final String lateString;
        }
    };

I usually end up writing a helper like this if I'm dealing with comment heavy code generation.

@gnunicorn
Copy link
Author

thanks, for the quick feedback @udoprog . Indeed forcing proc-macro to be at 1.0.55 (by using proc-macro2 = "=1.0.55" in my Cargo.toml) fixes the multi-line issue. Your example for docs also works well. Thanks!

feel free to close this as a duplicate of #39 then...

@udoprog
Copy link
Owner

udoprog commented Sep 25, 2023

Fix for #39 is incoming in #43.

@udoprog udoprog closed this as completed Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants