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

Adds a button to copy the code to the clipboard - index.js #2384

Closed
wants to merge 1 commit into from
Closed

Adds a button to copy the code to the clipboard - index.js #2384

wants to merge 1 commit into from

Conversation

grey4owl
Copy link

A very simple button that was missing in the upper right corner to copy the example code to the clipboard. I wasn't sure where to put the CSS so I added it directly to the element with js..

Screenshot from 2024-01-12 20-08-22

@grey4owl grey4owl requested a review from a team as a code owner January 12, 2024 19:15
@github-actions github-actions bot added the S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed label Jan 12, 2024
@GuillaumeGomez
Copy link
Member

So if I understand correctly, you want it for code examples in rustdoc pages, right? If so it's not the right place to do this. Please instead open an issue on rust-lang/rust. I prefer to warn: this is a very tricky UI change because it can be done in a lot of different ways. For example, your implementation cannot be used on mobile devices, although they're the ones where you'd want to use this feature the most.

For it to work on mobile devices, the button would need to be displayed all the time. Then comes the fun part: should it be put above the code example or hovering the code example with the risk of hiding code beneath it?

@syphar
Copy link
Member

syphar commented Jan 13, 2024

I wasn't sure if the examples came from the README file, which would mean we would have to look at our own docs.rs markdown renderer. But the screenshot above looks like it's from clap, where I don't find any examples.

So yes, if it's examples from the documentation pages, the way to do is to add this new (very useful IMO!) feature to rustdoc itself.

@syphar
Copy link
Member

syphar commented Jan 13, 2024

@grey4owl can you provide an example link to which examples are you talking about? Is it readme or documentation?

@grey4owl
Copy link
Author

grey4owl commented Jan 13, 2024

I was talking about any code blocks (<div class="example-wrap"> ) elements found in the documentation of all crates.io packages, but you are right, this should be added to the rustdoc directly so i will move it there.. Sorry 🥲

@grey4owl grey4owl closed this Jan 13, 2024
@syphar
Copy link
Member

syphar commented Jan 13, 2024

I was talking about any code blocks (<div class="example-wrap"> ) elements found in the documentation of all crates.io packages, but you are right, this should be added to the rustdoc directly so i will move it there.. Sorry 🥲

no worries, nothing to be sorry about. It can be complex to navigate the components and their connections.

Can you link the new issue here so I can follow it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants