about summary refs log tree commit diff
path: root/tests/rustdoc-js-std/macro-check.js
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-07-28 20:07:44 +0200
committerGitHub <noreply@github.com>2024-07-28 20:07:44 +0200
commita8cc24a1abd4327002ae67d981fd3830f002b49e (patch)
treef29d4a09dbb44bbac53e7781ceeea7919649e7e8 /tests/rustdoc-js-std/macro-check.js
parent78c857394ec8c01f06cb1df260c51178180a40e5 (diff)
parent26d72512e0c7e9077134173aa60d77ba08ac3e9a (diff)
downloadrust-a8cc24a1abd4327002ae67d981fd3830f002b49e.tar.gz
rust-a8cc24a1abd4327002ae67d981fd3830f002b49e.zip
Rollup merge of #125779 - GuillaumeGomez:copy-code, r=rustdoc-team
[rustdoc] Add copy code feature

This PR adds a "copy code" to code blocks. Since this is a JS only feature, the HTML is generated with JS when the user hovers the code block to prevent generating DOM unless needed.

Two things to note:
 1. I voluntarily kept the current behaviour of the run button (only when hovering a code block with a mouse) so it doesn't do anything on mobile. I plan to send a follow-up where the buttons would "expandable" or something. Still need to think which approach would be the best.
 2. I used a picture and not text like the run button to remain consistent with the "copy path" button. I'd also prefer for the run button to use a picture (like what is used in mdbook) but again, that's something to be discussed later on.

The rendering looks like this:

![Screenshot from 2024-06-03 21-29-48](https://github.com/rust-lang/rust/assets/3050060/a0b18f9c-b3dd-4a65-89a7-5a7a303b5c2b)
![Screenshot from 2024-06-03 21-30-20](https://github.com/rust-lang/rust/assets/3050060/b3b084ff-2716-4160-820b-d4774681a961)

It can be tested [here](https://guillaume-gomez.fr/rustdoc/bar/struct.Bar.html) (without the run button) and [here](https://guillaume-gomez.fr/rustdoc/foo/struct.Bar.html) (with the run button).

Fixes #86851.

r? ``@notriddle``
Diffstat (limited to 'tests/rustdoc-js-std/macro-check.js')
0 files changed, 0 insertions, 0 deletions