-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Add copy code to clipboard button in rustdoc
#119979
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jsha (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @jsha |
This comment has been minimized.
This comment has been minimized.
Before I can do a full review, could you please make CI pass (run EsLint errors
|
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@grey4owl Any updates on this? If you need any assistance with the CI failures, you can contact me on https://rust-lang.zulipchat.com/ for specific questions. |
@fmease Sorry i just doesn't have so much free time right now.. I made a new commit, maybe it will go through CI now 🥲 |
We still need to debate over this UI change: is it worth if there is code below it? Shouldn't we instead add a "space" at the top of the code block to put extra buttons there? For example, a while ago it was proposed to add an "expand" button to show the hidden lines (here). In addition, we could also move the "run" button into this "space". Overall, having overlaying buttons isn't great I think. |
This comment has been minimized.
This comment has been minimized.
@GuillaumeGomez I don't know, it's useful for me when I want to quickly copy the multi-line code (crate example) rather than manually selecting everything and maybe left out some lines. In terms of how the button is displayed, rust book and crates.io uses this hover effect approach as well. And I think it will be more useful here than it is used on the crates.io where you need to copy just one short line of code which you can easily remember.. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Didn't say it was not useful, I'd like for rustdoc to have this feature. I'm saying that the hover approach is likely not the right one. |
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
A very simple button that was missing in the upper right corner to copy the code blocks to the clipboard. It is hidden by default, but when you hover over the code block (
<pre>
) element then it appears.. It also works on mobile devices and it will appears after you tap on the code block.It looks like this:


r? @fmease