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: word wrap CamelCase in the item list table and sidebar #126247

Merged
merged 7 commits into from
Jul 30, 2024

Conversation

notriddle
Copy link
Contributor

@notriddle notriddle commented Jun 10, 2024

This is an alternative to #126209. That is, it fixes the issue that affects the very long type names in https://docs.rs/async-stripe/0.31.0/stripe/index.html#structs.

This is, necessarily, a pile of nasty heuristics. We need to balance a few issues:

  • Sometimes, there's no real word break. For example, BTreeMap should be BTree<wbr>Map, not B<wbr>Tree<wbr>Map.

  • Sometimes, there's a legit word break, but the name is tiny and the HTML overhead isn't worth it. For example, if we're typesetting TyCtx, writing Ty<wbr>Ctx would have an HTML overhead of 50%. Line breaking inside it makes no sense.

Screenshots

Before After
image image

@rustbot
Copy link
Collaborator

rustbot commented Jun 10, 2024

r? @fmease

rustbot has assigned @fmease.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jun 10, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 10, 2024

Some changes occurred in src/tools/compiletest

cc @jieyouxu

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@notriddle notriddle marked this pull request as draft June 10, 2024 23:58
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member

I'm not a big fan to this approach. Limiting the width of the item name seems better don't you think?

@notriddle
Copy link
Contributor Author

I remember awhile back that @fmease proposed experimenting with wbr to produce “more legible output”

The legibility comes from not having line breaks in the middle of words. For example, if the width limit were ten characters, it’s the difference between:

MyTypeDefi
nition

vs

MyType 
Definition

I suppose that adding a hard width limit doesn’t preclude doing this, so it might be worth doing this experiment anyway.

@GuillaumeGomez
Copy link
Member

Fair enough. 👍

@BradMarr
Copy link

BradMarr commented Jun 13, 2024

Wouldn't the <wbr> tag only apply if the width is already limited? Wouldn't this be more of a layer on top of #126209 instead of an alternative?

@notriddle
Copy link
Contributor Author

That's correct, @BradMarr.

@notriddle notriddle changed the title rustdoc: word wrap CamelCase in the item list table rustdoc: word wrap CamelCase in the item list table and sidebar Jul 6, 2024
@notriddle notriddle force-pushed the notriddle/word-wrap-item-table branch from 06ce2e0 to b7f202a Compare July 7, 2024 02:09
@notriddle notriddle marked this pull request as ready for review July 7, 2024 02:09
@rustbot
Copy link
Collaborator

rustbot commented Jul 7, 2024

Some changes occurred in GUI tests.

cc @GuillaumeGomez

@notriddle notriddle added T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. and removed T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) A-testsuite Area: The testsuite used to check the correctness of rustc labels Jul 7, 2024
@notriddle notriddle force-pushed the notriddle/word-wrap-item-table branch from b7f202a to a32cb15 Compare July 7, 2024 02:17
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 7, 2024
@notriddle notriddle removed A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 7, 2024
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the A-testsuite Area: The testsuite used to check the correctness of rustc label Jul 7, 2024
@notriddle notriddle force-pushed the notriddle/word-wrap-item-table branch from e277d8e to 25d4152 Compare July 29, 2024 15:47
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 29, 2024
@notriddle
Copy link
Contributor Author

@bors r=GuillaumeGomez

@bors
Copy link
Contributor

bors commented Jul 29, 2024

📌 Commit 25d4152 has been approved by GuillaumeGomez

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 29, 2024
@notriddle notriddle removed A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 29, 2024
@rust-log-analyzer

This comment has been minimized.

@notriddle notriddle force-pushed the notriddle/word-wrap-item-table branch from 25d4152 to 85b1ddb Compare July 29, 2024 16:17
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 29, 2024
@rust-log-analyzer

This comment has been minimized.

@notriddle notriddle force-pushed the notriddle/word-wrap-item-table branch from 85b1ddb to ac303df Compare July 29, 2024 17:31
@notriddle
Copy link
Contributor Author

@bors r=GuillaumeGomez

@bors
Copy link
Contributor

bors commented Jul 29, 2024

📌 Commit ac303df has been approved by GuillaumeGomez

It is now in the queue for this repository.

@notriddle notriddle removed A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 29, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 29, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#126247 (rustdoc: word wrap CamelCase in the item list table and sidebar)
 - rust-lang#128104 (Not lint pub structs without pub constructors intentionally)
 - rust-lang#128153 (Stop using `MoveDataParamEnv` for places that don't need a param-env)
 - rust-lang#128284 (Stabilize offset_of_nested)
 - rust-lang#128342 (simplify the use of `CiEnv`)
 - rust-lang#128355 (triagebot: make sure Nora is called Nora)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9aedec9 into rust-lang:master Jul 30, 2024
6 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Jul 30, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 30, 2024
Rollup merge of rust-lang#126247 - notriddle:notriddle/word-wrap-item-table, r=GuillaumeGomez

rustdoc: word wrap CamelCase in the item list table and sidebar

This is an alternative to rust-lang#126209. That is, it fixes the issue that affects the very long type names in https://docs.rs/async-stripe/0.31.0/stripe/index.html#structs.

This is, necessarily, a pile of nasty heuristics. We need to balance a few issues:

- Sometimes, there's no real word break. For example, `BTreeMap` should be `BTree<wbr>Map`, not `B<wbr>Tree<wbr>Map`.

- Sometimes, there's a legit word break, but the name is tiny and the HTML overhead isn't worth it. For example, if we're typesetting `TyCtx`, writing `Ty<wbr>Ctx` would have an HTML overhead of 50%. Line breaking inside it makes no sense.

# Screenshots

| Before | After |
| ------ | ----- |
| ![image](https://github.com/rust-lang/rust/assets/1593513/d51201fd-46c0-4f48-aee6-a477eadba288) | ![image](https://github.com/rust-lang/rust/assets/1593513/d8e77582-adcf-4966-bbfd-19dfdad7336a)
@notriddle notriddle deleted the notriddle/word-wrap-item-table branch July 30, 2024 03:24
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.

9 participants