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

How to disable formatting for comments? #4787

Closed
hirrolot opened this issue Apr 5, 2021 · 3 comments
Closed

How to disable formatting for comments? #4787

hirrolot opened this issue Apr 5, 2021 · 3 comments

Comments

@hirrolot
Copy link

hirrolot commented Apr 5, 2021

I have an MD table like this:

| Feature | Description |
|----------|----------|
| blah | some long long long long long long long long line |

I also have wrap_comments = true in my rustfmt.toml. As a result, rustfmt breaks the long line and disfigures the table. The comment itself is located at the top level of a .rs file and must be treated as a public documentation.

Can I tell rustfmt to skip this table?

@hirrolot
Copy link
Author

hirrolot commented Apr 5, 2021

As a workaround:

#![cfg_attr(feature = "nightly", feature(extended_key_value_attributes))]

// ...

#![cfg_attr(feature = "nightly", doc = include_str!("features.txt"))]

Where features.txt is a file that contains the vicious comment.

@jyn514
Copy link
Member

jyn514 commented Apr 6, 2021

#![cfg_attr(feature = "nightly", doc = include_str!("features.txt"))]

FYI this doesn't work like you expect it to: rust-lang/rust#82768

@calebcartwright
Copy link
Member

Thanks for reaching out but going to close as a duplicate of #4210. Please let me know if you feel like this is different/not a duplicate.

The fix has already been made but just hasn't been released. I will try to pull this into the next release, though no guarantees.

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

3 participants