-
Notifications
You must be signed in to change notification settings - Fork 898
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
URL in comment prevents formatting #5634
Comments
According to the comments (cf below) in rustfmt source, this is intended behavior, but I don't understand why, and couldn't find a discussion of why in the tracking issues. Comments frequently have URL, including in markdown links in them, so I think it would be best not to have this limitation. Lines 799 to 803 in ee2bed9
|
Thanks for reaching out. This is indeed intended behavior. We've had several issues in the past where breaking urls has been an issue. In the worst case breaking urls would prevent rustdoc from rendering them properly so we're erring on the side of caution and not breaking those lines at all. Check out the following issues for reference: #506, #3787, #5095, #5260 It would be great if someone could help update the docs for |
I see how it could have break in the past but isn't it something that can be fixed? Would you be open to a PR restoring wrapping of comments containing urls? It seems to me that this is merely a case of correctly detecting all possible URL formats with an exhaustive enough regex. Am I missing something? |
I think the current implementation could be made more permissive, but we still wouldn't want to introduce line break within a URL. You'll likely need to change how
Sorry, would you mind elaborating a little on this. Are you referring to the current implementation or what you'd need to do to solve the issue? |
All that being said, I would still like to update the docs to better describe cases when we won't wrap comments |
I've added documentation but still would like to give a go to the underlying issue and get formatting of comments with urls to work (without splitting urls themselves of course). However, I believe this means the issue should be untagged "documentation" and possibly "good-first-issue". |
@krtab I'd like to close this once we update the docs to better describe how the feature is currently intended to work. That being said, I'd be more than happy to review a follow up PR to expand on the current behavior of |
* Document which comments are excluded from wrapping Cf: #5634 * Add examples in wrap_commments doc * fix failling tests
@mladedav appreciate you pointing that out 😁 |
When using rustfmt to wrap doc comments, having a URL in the comments prevents any wrapping from happening.
Example:
Becomes:
The config used for the tests was:
The text was updated successfully, but these errors were encountered: