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

<code> in docblocks should use "overflow-wrap" CSS rule #89618

Closed
GuillaumeGomez opened this issue Oct 7, 2021 · 5 comments · Fixed by #89632
Closed

<code> in docblocks should use "overflow-wrap" CSS rule #89618

GuillaumeGomez opened this issue Oct 7, 2021 · 5 comments · Fixed by #89632
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

@GuillaumeGomez
Copy link
Member

Otherwise, if too long we can't read them:

Screenshot from 2021-10-07 12-01-37

With word-wrap rule:

Screenshot from 2021-10-07 12-03-21

@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-rustdoc-ui Area: Rustdoc UI (generated HTML) labels Oct 7, 2021
@GuillaumeGomez GuillaumeGomez self-assigned this Oct 7, 2021
@GuillaumeGomez GuillaumeGomez changed the title <code> in docblocks should use "work-wrap" CSS rule <code> in docblocks should use "word-wrap" CSS rule Oct 7, 2021
@nox
Copy link
Contributor

nox commented Oct 7, 2021

You probs want overflow-wrap: break-word so that it tries to not wrap mid-word (but still does if it can't do otherwise).

@GuillaumeGomez
Copy link
Member Author

With your suggestion it gives:

Screenshot from 2021-10-07 13-53-43

It's weird but in a different way haha.

@the8472
Copy link
Member

the8472 commented Oct 7, 2021

We can tell the browser where to break words by inserting <wbr> in the right places. E.g. Refresh<wbr>Kind. Together with some other CSS properties that should give us full control where it'll do the breaking.

@jsha jsha changed the title <code> in docblocks should use "word-wrap" CSS rule <code> in docblocks should use "overflow-wrap" CSS rule Oct 7, 2021
@jsha
Copy link
Contributor

jsha commented Oct 7, 2021

@nox it's not clear to me that break-word makes wrapping word-aware (that would be quite a task!)

https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap

anywhere
To prevent overflow, an otherwise unbreakable string of characters — like a long word or URL — may be broken at any point if there are no otherwise-acceptable break points in the line. No hyphenation character is inserted at the break point. Soft wrap opportunities introduced by the word break are considered when calculating min-content intrinsic sizes.

break-word
The same as the anywhere value, with normally unbreakable words allowed to be broken at arbitrary points if there are no otherwise acceptable break points in the line, but soft wrap opportunities introduced by the word break are NOT considered when calculating min-content intrinsic sizes.

In other words, overflow-wrap: anywhere vs overflow-wrap: break-word differ only in whether the wrap affects min-content:

The min-content sizing keyword represents the intrinsic minimum width of the content.
For text content this means that the content will take all soft-wrapping opportunities, becoming as small as the longest word.

Emphasis mine.

We don't explicitly use min-content in our CSS as far as I can tell, but looking at the screenshots @GuillaumeGomez shared, perhaps it is introduced somewhere by browser intrinsics?

Long story short, I think we should use overflow-wrap: anywhere. It produces nicer results in these screenshots, and break-word isn't documented to provide benefits that we care about.

@nox
Copy link
Contributor

nox commented Oct 8, 2021

@jsha I'm certainly not a CSS expert, I just meant "let's not break idents in the middle" and assumed break-word would be enough for that. It seems like @the8472 gave the proper answer for breaking correctly around :: instead of in the middle of the words.

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.

4 participants