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: Long type names result in weird-looking documentation #120595

Closed
Andrewp2 opened this issue Feb 2, 2024 · 2 comments · Fixed by #127418
Closed

rustdoc: Long type names result in weird-looking documentation #120595

Andrewp2 opened this issue Feb 2, 2024 · 2 comments · Fixed by #127418
Assignees
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Andrewp2
Copy link

Andrewp2 commented Feb 2, 2024

Crates with long type names result in a strange-looking error, see https://docs.rs/async-stripe/0.31.0/stripe/

image

I've tested this on Chrome and Firefox, and by building the docs locally from https://github.com/arlyon/async-stripe

I believe the text is rendering vertically due to long type names like https://docs.rs/async-stripe/0.31.0/stripe/enum.PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus.html which are auto-generated from OpenAPI.

Link to original issue arlyon/async-stripe#488

@Andrewp2 Andrewp2 added the C-bug Category: This is a bug. label Feb 2, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 2, 2024
@fmease fmease added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 3, 2024
@Urgau
Copy link
Member

Urgau commented May 3, 2024

The issue is related to the overflow-wrap: break-word rule which prevents breaking anywhere in the type name. Unfortunately using overflow-wrap: anywhere breaks core::arch.

We even have a comment about the weird behaviour in the code, not sure how to fix this.

/* In most contexts we use `overflow-wrap: anywhere` to ensure that we can wrap
as much as needed on mobile (see
tests/rustdoc-gui/type-declaration-overflow.goml for an example of why
this matters). The `anywhere` value means:
"Soft wrap opportunities introduced by the word break are considered when
calculating min-content intrinsic sizes."
https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap#values
For table layouts, that becomes a problem: the browser tries to make each
column as narrow as possible, and `overflow-wrap: anywhere` means it can do
so by breaking words - even if some other column could be shrunk without
breaking words! This shows up, for instance, in the `Structs` / `Modules` /
`Functions` (etcetera) sections of a module page, and when a docblock
contains a table.
So, for table layouts, override the default with break-word, which does
_not_ affect min-content intrinsic sizes.
*/
table,
.item-table {
overflow-wrap: break-word;
}

@BradMarr
Copy link

BradMarr commented Jun 9, 2024

@rustbot claim

@bors bors closed this as completed in 7c1bf86 Jul 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 19, 2024
Rollup merge of rust-lang#127418 - GuillaumeGomez:wrap-too-long-type-name, r=notriddle

Wrap too long type name

Fixes rust-lang#120595.

Takeover of rust-lang#126209.

cc `@BradMarr`
r? `@notriddle`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants