Skip to content

rustdoc: Move the "copy path" button out of the HTML and generate it with JS - #164447

Open
GuillaumeGomez wants to merge 1 commit into
rust-lang:mainfrom
GuillaumeGomez:move-copy-path-out-of-js
Open

GuillaumeGomez wants to merge 1 commit into
rust-lang:mainfrom
GuillaumeGomez:move-copy-path-out-of-js

Conversation

@GuillaumeGomez

Copy link
Copy Markdown
Member

There are a few things in the HTML that are only used when JS is enabled. So instead of generating them for each page, better generate them with JS. I'll send a few PRs after this one for each element.

r? @notriddle

@rustbot

rustbot commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @lolbinarycat

@rustbot rustbot added A-rustdoc-js Area: Rustdoc's JS front-end 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Oct 16, 2026
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
GuillaumeGomez force-pushed the move-copy-path-out-of-js branch from 50601fc to 36fefb8 Compare October 16, 2026 21:33

@notriddle notriddle left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As it is now, on a slow connection you can get layout shift. It's not a lot, but it's noticeable, and we've always done a pretty good job to avoid it before.

Screen.Recording.2026-10-16.at.19.59.06.mov

To avoid this, I think you could inserting the copy path button in [RustdocToolbarElement::connectedCallback][], or a new custom element, or a MutationObserver registered in storage.js.

View changes since this review

// We check that the clipboard value is the expected one.
assert-clipboard: "test_docs"

// Now check the presence of the "copy code" button. Above we already checked for items, crate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

“Copy code”? Don’t you mean “copy path”?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes. ^^'

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-js Area: Rustdoc's JS front-end S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. 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.

4 participants