-
Notifications
You must be signed in to change notification settings - Fork 899
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
Do not break long urls in comments. #506
Comments
What should we do with such comments? |
Leave it as it is. Break a url is bad because we cannot click it anymore... |
We could try to break before the URL, if we are into breaking comments, otherwise leave as is. |
Note that this also breaks in the case of the (style-guide-recommended) reference-style link, so this: /// Here's a snippet talking about [higher-kinded types][1]. We might go on...
[1]: https://github.com/rust-lang/rfcs/blob/master/text/0195-associated-items.md#encoding-higher-kinded-types becomes this: /// Here's a snippet talking about [higher-kinded types][1]. We might go on...
///
/// [1]: https://github.com/rust-lang/rfcs/blob/master/text/0195-associated-
/// items.md#encoding-higher-kinded-types I think the best solution is:
|
There should be no breakings in reference-style links as this brakes formatting also:
becomes this:
|
This gets left as is by default, but the bug still exists if we turn on comment formatting |
Closed by #911. |
When calling rustfmt on a file with: //! For a quick overview see
//! [wikipedia](https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#BMI1_.28Bit_Manipulation_Instruction_Set_1.29).
//! The reference is [Intel 64 and IA-32 Architectures Software Developer's
//! Manual Volume 2: Instruction Set Reference,
//! A-Z](http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf).
//!
I get errors of the form: Rustfmt failed at ...: line exceeded maximum length (sorry)
Rustfmt failed at ...: line exceeded maximum length (sorry) Is this normal? Seems related to this issue but this issue is closed. |
It also seems to fail when an URL is in a list in a comment. For example here: /// # Intrinsic (when available BMI1)
///
/// - [`BEXTR`](http://www.felixcloutier.com/x86/BEXTR.html): Bit field extract (supports 32/64 bit registers).
///
That could be formatted to something like /// # Intrinsic (when available BMI1)
///
/// - [`BEXTR`](http://www.felixcloutier.com/x86/BEXTR.html): Bit field
/// extract (supports 32/64 bit registers).
///
|
I don't think #911 fixes this, because you split on punctuation. As an example, the following:
is converted to:
|
Related: steveklabnik/rustdoc#178 Technically, markdown can handle URLs split over multiple lines, so rustfmt should actually follow markdown URL splitting style. rustdoc cannot currently handle this, but once that is fixed, this could be fixed too...
Why can't you click it anymore? Your editor should know that in Rust mode comments follow markdown, and thus recognize an URL even when its split across multiple line as long as the split follows markdown style. |
Triage: rustfmt no longer splits comments with URLs. |
@gnzlbg Do you have a source for this?
I can't find anything about URL breaking in the original, or any of the popular, markdown "specs". It would be very useful in producing test material for related issues. |
// https://github.com/rust-lang/rfcs/blob/master/text/0195-associated-items.md#encoding-higher-kinded-types
is format to this
The text was updated successfully, but these errors were encountered: