Skip to content

doc_comment_code_block_width doesn't work in inner comments #5461

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

Open
robertbastian opened this issue Jul 21, 2022 · 8 comments
Open

doc_comment_code_block_width doesn't work in inner comments #5461

robertbastian opened this issue Jul 21, 2022 · 8 comments
Labels
a-comments only-with-option requires a non-default option value to reproduce p-low

Comments

@robertbastian
Copy link

robertbastian commented Jul 21, 2022

Code blocks in a //! doc comment don't seem to be formatted.

mod foo {
  //! ```
  //! horribly .formatted(code
  //! );
  //! ```
}

This is on nightly 2022-07-19 and on an older one as well.

@calebcartwright
Copy link
Member

Please update the issue description with a valid, minimal snippet that reproduces the behavior you are describing, along with relevant details like the version of rustfmt you are using and your config file

@calebcartwright calebcartwright added the needs-mcve needs a Minimal Complete and Verifiable Example label Jul 21, 2022
@ytmimi
Copy link
Contributor

ytmimi commented Jul 21, 2022

@robertbastian I think we still need more context in order to figure out what's going on. Could you please provide a complete snippet where you're experiencing this problem.

Also as @calebcartwright mentioned having the version of rustfmt and any relevant configuration options your using besides format_code_in_doc_comments is really important for us to reproduce the issue.

@robertbastian
Copy link
Author

robertbastian commented Jul 21, 2022

Updated

@calebcartwright
Copy link
Member

calebcartwright commented Jul 22, 2022

Thank you for updating, but I'm unable to reproduce using rustfmt from source, the latest nightly, nor even stable for that matter. There haven't been any released changes to rustfmt in the last ~2 weeks either so I don't think the latest nightly 7-21 vs 7-19 will make a difference.

Are you sure that nightly rustfmt is being invoked, and that format_code_in_doc_comments is set to true? How are you executing rustfmt, are you running rustfmt ... directly, running cargo fmt, using an editor, etc. ?

$ rustfmt +nightly --version
rustfmt 1.5.1-nightly (62b272d 2022-07-21)
$ rustfmt +nightly lib.rs --check --config format_code_in_doc_comments=true
Diff in /......................../lib.rs at line 1:
 mod foo {
-  //! ```
-  //! horribly .formatted(code
-  //! );
-  //! ```
+    //! ```
+    //! horribly.formatted(code);
+    //! ```
 }

@robertbastian
Copy link
Author

Oh sorry I don't seem to have invoked rustfmt correctly. rustfmt +nightly --config format_code_in_doc_comments=true,doc_comment_code_block_width=80 provider/adapters/src/fallback/mod.rs doesn't work with the file at https://github.com/unicode-org/icu4x/blob/583de584f0ba1cfe3402915989f57aa586c0ca06/provider/adapters/src/fallback/mod.rs. The inner doc comment has a line that's too long, and also if you mess with any other formatting it fails. Without the max_length flag it works though.

@robertbastian robertbastian changed the title format_code_in_doc_comments doesn't work in inner comments doc_comment_code_block_width doesn't work in inner comments Jul 22, 2022
@ytmimi
Copy link
Contributor

ytmimi commented Jul 22, 2022

if you mess with any other formatting it fails.

Could you elaborate a little more on what you types of formatting you tried messing with?

Without the max_length flag it works though.

Are you saying that doc_comment_code_block_width=80 is causing the issue for you? and that running the command without it works?

@robertbastian
Copy link
Author

I introduced a space in some foo .to_string() call (below the line that is too long) that didn't get fixed. Without the doc_comment_code_block_width=80 it does get fixed.

@ytmimi
Copy link
Contributor

ytmimi commented Jul 22, 2022

Alright, I'll try to take a look into this at some point. For now going to link the tracking issues for doc_comment_code_block_width #5415

@ytmimi ytmimi added a-comments only-with-option requires a non-default option value to reproduce p-low and removed needs-mcve needs a Minimal Complete and Verifiable Example labels Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-comments only-with-option requires a non-default option value to reproduce p-low
Projects
None yet
Development

No branches or pull requests

3 participants