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

[rustdoc] Add new setting to wrap source code lines when too long #136991

Merged
merged 4 commits into from
Feb 24, 2025

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Feb 13, 2025

Fixes #127334.

Wrapped lines look like this:

image

It works in both source code pages and doc pages.

You can test it here.

r? @notriddle

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Feb 13, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 13, 2025

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @jsha

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Feb 14, 2025

☔ The latest upstream changes (presumably #137001) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Fixed TS errors. :)

@notriddle
Copy link
Contributor

notriddle commented Feb 14, 2025

Good choice...

... we need to redesign the settings popover. That list of checkboxes is a wall. It could just be adding a line between them to divide the panel into sections with an implied theme, or maybe splitting it into tabs.

@notriddle
Copy link
Contributor

Possibility 1: sections
image

Possibility 2: tabs
image

@GuillaumeGomez
Copy link
Member Author

I think it should be part of a UI discussion first. I think I prefer the second approach though.

Please open an issue so it can be discussed separately.

@notriddle
Copy link
Contributor

#137050

@GuillaumeGomez
Copy link
Member Author

Thanks! Anything else to be done here?

@notriddle
Copy link
Contributor

notriddle commented Feb 15, 2025

The setting should probably be called "Word wrap source code".

Why "word wrap"?

The phrase "word wrap" is what almost everybody calls the feature:

VSCode Eclipse Sublime Text Windows Notepad Mousepad Notepad++ Emacs
image Screenshot 2025-02-14 170530 https://www.emacswiki.org/emacs/LineWrap#h5o-7

Almost, because here's a few that call it something else, but no usage seems dominant other than "word wrap."

IntelliJ ("soft wrap") Vim ("linebreak") Gedit ("text wrap")
https://neovim.io/doc/user/usr_25.html#edit-no-break

I also checked Apple TextEdit, but couldn't find a way to turn word wrapping off.

Why "source code?"

Wiktionary describes source code as uncountable, and the Jargon File also describes code as a mass noun (these are synonyms).

I checked several other dictionaries, but Collaborative International Dictionary of English butter and Merriam-Webster butter don't mention that it's a mass noun anywhere, even though I know it is.

I considered calling it "code examples," but this setting also changes how crate code pages are typeset, so probably not.

@GuillaumeGomez
Copy link
Member Author

Sounds good to me, updating the name.

@rustbot rustbot added the T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. label Feb 15, 2025
@GuillaumeGomez
Copy link
Member Author

Done!

@rust-log-analyzer

This comment has been minimized.

@notriddle notriddle removed the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Feb 16, 2025
@notriddle
Copy link
Contributor

@rfcbot poll

@rfcbot
Copy link

rfcbot commented Feb 16, 2025

Team member @notriddle has asked teams: T-rustdoc-frontend, for consensus on:

@camelid
Copy link
Member

camelid commented Feb 23, 2025

Sorry, I missed this poll. Seems reasonable to me. A little unfortunate how much CSS needs to be changed for this, but that's just an implementation concern.

@GuillaumeGomez
Copy link
Member Author

Poll now has majority so let's r+ it.

@bors r=notriddle rollup

@bors
Copy link
Contributor

bors commented Feb 23, 2025

📌 Commit a1471f3 has been approved by notriddle

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 23, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Feb 24, 2025
…triddle

[rustdoc] Add new setting to wrap source code lines when too long

Fixes rust-lang#127334.

Wrapped lines look like this:

![image](https://github.com/user-attachments/assets/92006a27-ed1e-4beb-91f2-f453b72c5e1a)

It works in both source code pages and doc pages.

You can test it [here](https://rustdoc.crud.net/imperio/code-wrapping/bar/index.html).

r? `@notriddle`
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 24, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang#131282 (std: detect stack overflows in TLS destructors on UNIX)
 - rust-lang#136610 (Allow `IndexSlice` to be indexed by ranges.)
 - rust-lang#136991 ([rustdoc] Add new setting to wrap source code lines when too long)
 - rust-lang#137393 (Stabilize `unbounded_shifts`)
 - rust-lang#137482 (Windows: use existing wrappers in `File::open_native`)
 - rust-lang#137484 (Fix documentation for unstable sort on slice)
 - rust-lang#137491 (Tighten `str-to-string-128690.rs``CHECK{,-NOT}`s to make it less likely to incorrectly fail with symbol name mangling)
 - rust-lang#137495 (Added into_value function to ControlFlow<T, T>)
 - rust-lang#137501 (Move `impl` blocks out of `rustc_middle/src/mir/syntax.rs`)

Failed merges:

 - rust-lang#137489 (remove `#[rustc_intrinsic_must_be_overridde]`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 24, 2025
Rollup of 10 pull requests

Successful merges:

 - rust-lang#136610 (Allow `IndexSlice` to be indexed by ranges.)
 - rust-lang#136991 ([rustdoc] Add new setting to wrap source code lines when too long)
 - rust-lang#137061 (Unstable `gen_future` Feature Tracking  )
 - rust-lang#137393 (Stabilize `unbounded_shifts`)
 - rust-lang#137482 (Windows: use existing wrappers in `File::open_native`)
 - rust-lang#137484 (Fix documentation for unstable sort on slice)
 - rust-lang#137491 (Tighten `str-to-string-128690.rs``CHECK{,-NOT}`s to make it less likely to incorrectly fail with symbol name mangling)
 - rust-lang#137495 (Added into_value function to ControlFlow<T, T>)
 - rust-lang#137501 (Move `impl` blocks out of `rustc_middle/src/mir/syntax.rs`)
 - rust-lang#137505 (Add a span to `CompilerBuiltinsCannotCall`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8133652 into rust-lang:master Feb 24, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Feb 24, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 24, 2025
Rollup merge of rust-lang#136991 - GuillaumeGomez:code-wrapping, r=notriddle

[rustdoc] Add new setting to wrap source code lines when too long

Fixes rust-lang#127334.

Wrapped lines look like this:

![image](https://github.com/user-attachments/assets/92006a27-ed1e-4beb-91f2-f453b72c5e1a)

It works in both source code pages and doc pages.

You can test it [here](https://rustdoc.crud.net/imperio/code-wrapping/bar/index.html).

r? ``@notriddle``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[rustdoc] Feature Request: Allow code wrapping
7 participants