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

Add width for codeblocks in comments #5372

Merged

Conversation

sec65
Copy link
Contributor

@sec65 sec65 commented Jun 7, 2022

Resolves #5359

Adds a new doc_comment_code_block_width configuration (default: 100), which limits the code blocks in comments, if format_code_in_doc_comments is true.

@calebcartwright
Copy link
Member

Thank you for this! I'm in the process of prepping the next release but will circle back to this afterwards

Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this looks great! Couple small items but should be good to merge afterwards 🚀

- **Default value**: `100`
- **Possible values**: any positive integer that is less than or equal to the value specified for [`max_width`](#max_width)
- **Stable**: No (tracking issue: [#5359](https://github.com/rust-lang/rustfmt/issues/5359))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to include a link to the format_code_in_doc_comments option, similar to what's done for other options https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#array_width

What do you think?

@@ -0,0 +1,17 @@
// rustfmt-max_width: 50
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests look good! However, we actually put tests for config option in a special directory, named configs under the source and target dirs

Please move these when you get a chance, and with that move you may be able to rename the files (though don't feel obligated to do so)
https://github.com/rust-lang/rustfmt/tree/master/tests/source/configs

@sec65
Copy link
Contributor Author

sec65 commented Jun 16, 2022

@calebcartwright Thanks for your review. I changed the docu and moved the tests to the config folder and renamed the files to mach with the tested option.

Short question: In one of the test cases I wanted to use (and by that test) the default value, but there seems to be a check in the configs folder, that the config option has to be set explicitily (so I did that now). Or is there a way around it?

@calebcartwright
Copy link
Member

Good question! It's actually better to have the options explicitly set. For these tests we're just trying to validate the formatting behavior when options have a certain value and not so concerned with using these to validate defaults.

Once an option is stabilized we can't change the default and while options remain unstable there's still a chance that we could change the defaults, all of which makes it better for the system & idempotence tests to be explicit

@calebcartwright
Copy link
Member

Everything looks good to me, thanks you and nice first contribution!

@calebcartwright calebcartwright merged commit 33c6074 into rust-lang:master Jun 17, 2022
@calebcartwright calebcartwright added release-notes Needs an associated changelog entry and removed release-notes Needs an associated changelog entry labels Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New config option to support lower width limit on code blocks in doc comments
2 participants