You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would be nice to have a setting (or just a button) that could have the code wrap, gets tiring if you are reading lots of code on your phone to scroll back and forth.
My bad if this has been requested before, I didn't see it in any issues yet
Sorry I still don't understand what's being asked. ^^'
Are you talking to me or...? I mean wrapping the code blocks on the rust docs website. As in not having any overflow-x..? Having the text wrap to the next line, so you don't need to scroll left and right, to read the code block
In case it's not clear for everyone, let me expand a bit (please correct me if I'm wrong @aramrw):
Currently, the code examples in Rust HTML documentation are scrollable if they are too wide. The idea here would be to add a setting allowing for the code examples to instead wrap to the next line.
Now for the implementation: we need to be careful how this new setting would interact with the line numbers on the left (if the setting is enabled).
One thing I'm not clear about: @aramrw, would you want this setting to be applied to both code examples and source code pages or only to code examples?
I think it's fine to add such a setting. If @rust-lang/rustdoc-frontend agrees, I'll add it.
One thing I'm not clear about: @aramrw, would you want this setting to be applied to both code examples and source code pages or only to code examples?
If it's possible to add it for both the code examples & the source code it would be much appreciated 👍🏼
One idea: instead of having an option for this, maybe just make wrapping the default on mobile devices (i.e., screens that are sufficiently narrow by some heuristic). I'm wary of requiring too much configuration of rustdoc.
#88545 Looks like it was grid layout and 1000 items, maybe?
I was looking for this discussion, thanks so much! So it was not for tables but for grids, good to know! One less problem to worry about.
One idea: instead of having an option for this, maybe just make wrapping the default on mobile devices (i.e., screens that are sufficiently narrow by some heuristic). I'm wary of requiring too much configuration of rustdoc.
We enter in the tricky area of personal taste. It's a case where being able to ask all rust doc users would be super useful.
I've been meaning to come here and post exactly what @camelid said. Our default position should be to not introduce new settings but try to just do the best thing. If we put it behind a setting, very few people will actually know about it and use it, but we will still bear the full burden of maintaining both versions.
In this case, the right thing is clearly to line-wrap on all platforms (not just mobile). Horizontal scrolling is a terrible experience on desktop / wide screens too.
Another issue I didn't think of is that we use style with CSS classes across lines (so if you have a multi-line comment, it's currently only one element). It would greatly increase the size of the DOM. This feature is definitely more tricky than I initially thought...
Yep, found an acceptable middle-ground for this feature to be done in #136829. It's just the first step but adding this setting should be pretty easy/quick from there.
Activity
syphar commentedon Jul 4, 2024
Hi,
thank you for the idea.
About which code views are you talking? can you provide example URLs?
I'm asking because there are actually two separate ones:
aramrw commentedon Jul 4, 2024
Like it says
Runin the top right, could also have a wrap button there maybe if possible?https://doc.rust-lang.org/std/rc/index.html#examples
syphar commentedon Jul 4, 2024
Ah, that's even option 3),
not the code views for the crate itself, but code blocks in the docs.
I'm not sure if this is a rustdoc issue (where we don't have the "run" button yet), or an issue for the stdlib docs.
@GuillaumeGomez ?
GuillaumeGomez commentedon Jul 4, 2024
Sorry I still don't understand what's being asked. ^^'
aramrw commentedon Jul 4, 2024
Are you talking to me or...? I mean wrapping the code blocks on the rust docs website. As in not having any overflow-x..? Having the text wrap to the next line, so you don't need to scroll left and right, to read the code block
GuillaumeGomez commentedon Jul 4, 2024
Oh I see. So a change in rustdoc. Moving the issue to the right repository.
[-]Feature Request: Allow code wrapping[/-][+][rustdoc] Feature Request: Allow code wrapping[/+]GuillaumeGomez commentedon Jul 4, 2024
In case it's not clear for everyone, let me expand a bit (please correct me if I'm wrong @aramrw):
Currently, the code examples in Rust HTML documentation are scrollable if they are too wide. The idea here would be to add a setting allowing for the code examples to instead wrap to the next line.
Now for the implementation: we need to be careful how this new setting would interact with the line numbers on the left (if the setting is enabled).
One thing I'm not clear about: @aramrw, would you want this setting to be applied to both code examples and source code pages or only to code examples?
I think it's fine to add such a setting. If @rust-lang/rustdoc-frontend agrees, I'll add it.
aramrw commentedon Jul 4, 2024
If it's possible to add it for both the code examples & the source code it would be much appreciated 👍🏼
4 remaining items
jsha commentedon Jul 8, 2024
camelid commentedon Jul 8, 2024
One idea: instead of having an option for this, maybe just make wrapping the default on mobile devices (i.e., screens that are sufficiently narrow by some heuristic). I'm wary of requiring too much configuration of rustdoc.
GuillaumeGomez commentedon Jul 8, 2024
I was looking for this discussion, thanks so much! So it was not for tables but for grids, good to know! One less problem to worry about.
We enter in the tricky area of personal taste. It's a case where being able to ask all rust doc users would be super useful.
jsha commentedon Jul 8, 2024
I've been meaning to come here and post exactly what @camelid said. Our default position should be to not introduce new settings but try to just do the best thing. If we put it behind a setting, very few people will actually know about it and use it, but we will still bear the full burden of maintaining both versions.
In this case, the right thing is clearly to line-wrap on all platforms (not just mobile). Horizontal scrolling is a terrible experience on desktop / wide screens too.
This page has an example of doing line numbers with wrapping. It uses CSS counters, and seems pretty tidy.
GuillaumeGomez commentedon Jul 10, 2024
It can work for code examples, but not for source code as we need them to be link. But noted for the horizontal scrolling. Will make our work simpler.
GuillaumeGomez commentedon Jul 17, 2024
Another issue I didn't think of is that we use style with CSS classes across lines (so if you have a multi-line comment, it's currently only one element). It would greatly increase the size of the DOM. This feature is definitely more tricky than I initially thought...
aramrw commentedon Oct 9, 2024
any updates...?
GuillaumeGomez commentedon Feb 11, 2025
Yep, found an acceptable middle-ground for this feature to be done in #136829. It's just the first step but adding this setting should be pretty easy/quick from there.
Rollup merge of rust-lang#136829 - GuillaumeGomez:move-line-numbers-i…
Unrolled build for rust-lang#136829
GuillaumeGomez commentedon Feb 13, 2025
Opened PR to add the feature in #136991.
Rollup merge of rust-lang#136991 - GuillaumeGomez:code-wrapping, r=no…
Rollup merge of rust-lang#136991 - GuillaumeGomez:code-wrapping, r=no…
Unrolled build for rust-lang#136991