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

Replace nbsp in all rustdoc code blocks #106125

Closed
wants to merge 2 commits into from
Closed

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Dec 24, 2022

Fixes #106098. This makes code copyable from rustdoc rendered documentation into a Rust source file.

Tested by building the docs of syn and scanning for any missing indentation.

white-space: pre makes consecutive spaces not collapse into one, and makes linebreaks not get inserted, exactly what   was doing.

@rustbot
Copy link
Collaborator

rustbot commented Dec 24, 2022

r? @notriddle

(rustbot has picked a reviewer for you, use r? to override)

@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 Dec 24, 2022
@rustbot
Copy link
Collaborator

rustbot commented Dec 24, 2022

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @Folyd, @jsha

@notriddle
Copy link
Contributor

Please run ./x test --bless src/test/rustdoc to update the rustdoc test HTML samples, and also fix the indentation in rustdoc.css to use tabs instead of spaces.

@est31
Copy link
Member

est31 commented Dec 24, 2022

cc @hsivonen

@@ -182,6 +182,7 @@ h4.code-header {
font-weight: 600;
margin: 0;
padding: 0;
white-space: pre;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what we want?

With the old setup, code headers were allowed to wrap, and there are GUI tests for it. in the notable traits popup.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are supposed to indeed.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
  IMAGE: x86_64-gnu-tools
##[endgroup]
From https://github.com/rust-lang/rust
 * branch              master     -> FETCH_HEAD
Searching for toolstate changes between f5c3dfdbbf06d5997079ac7339de5002f7ced2a3 and 52d1dfac2e7b9eb15d8adf7b0a2ddfeb1fff2501
Rustdoc was updated
##[group]Run src/ci/scripts/verify-channel.sh
src/ci/scripts/verify-channel.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
---
.......... (90/95)
.....      (95/95)


/checkout/src/test/rustdoc-gui/notable-trait.goml notable-trait... FAILED
[ERROR] (line 48) Error: Evaluation failed: assert didn't fail: for command `compare-elements-position-false: (
    "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
    "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
    ("y", "x"),
)`
[ERROR] (line 69) Error: Evaluation failed: The following errors happened: [different X values: 677.03125 (or 677) != 245]: for command `assert-position: (
    "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
    {"x": 245},
)`
[ERROR] (line 73) Error: Evaluation failed: The following errors happened: [different X values: 955.453125 (or 955) != 523]: for command `assert-position: (
    "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
    {"x": 523},
)`
[ERROR] (line 93) Error: Evaluation failed: The following errors happened: [different X values: 447.03125 (or 447) != 15]: for command `assert-position: (
    "//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
    {"x": 15},
)`
[ERROR] (line 97) Error: Evaluation failed: The following errors happened: [different X values: 725.453125 (or 725) != 293]: for command `assert-position: (
    "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",
    {"x": 293},
)`
[ERROR] (line 102) Error: Node is either not clickable or not an HTMLElement: for command `click: "//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']"`
Build completed unsuccessfully in 0:02:31

Copy link
Member Author

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave it to someone else to work out what to do about notable traits popup.

Copying code from those is a less common thing so maybe it's not so bad for notable traits popups to continue using nbsp. I still think the non-popup rendered APIs should never use nbsp.

@dtolnay dtolnay closed this Dec 29, 2022
@dtolnay dtolnay deleted the nbsp branch December 29, 2022 08:42
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Feb 3, 2023
…umeGomez

Replace nbsp in all rustdoc code blocks

Based on rust-lang#106125 by `@dtolnay` — this PR fixes the line wrapping bug.

Fixes rust-lang#106098. This makes code copyable from rustdoc rendered documentation into a Rust source file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use of   by rustdoc makes APIs not copyable into Rust source code
6 participants