Re: [PATCH] docs: add copy buttons for code blocks
From: Jonathan Corbet
Date: Mon Mar 30 2026 - 11:52:18 EST
Rito Rhymes <rito@xxxxxxxxxxxxxx> writes:
> Add a copy button to highlighted code blocks in the documentation
> that copies the full contents of the code block to the clipboard.
>
> This is faster and less error-prone than manually selecting and
> copying code from the page, especially for longer examples where
> part of the block can be accidentally missed.
>
> Keep the control hidden until the user interacts with the block so
> it stays out of the way during normal reading. Reveal it on hover,
> focus, and touch interaction, then copy the block contents to the
> clipboard with a small success or failure state.
>
> Signed-off-by: Rito Rhymes <rito@xxxxxxxxxxxxxx>
> Assisted-by: Codex:GPT-5.4
> Assisted-by: Claude Opus 4.6
> ---
> Live demo:
> https://kernel-docs-cp.ritovision.com/accounting/delay-accounting.html
Honestly, I don't think so.
Rito, who is asking for this feature? What is the use case? Does it
really justify adding a blob of JavaScript code to every view of the
kernel documentation - JavaScript that we will have to maintain going
forward?
Our goal here is to make the kernel documentation better, not to shovel
lots of code into the repository.
If you can get some acks from established kernel developers saying that
they want this change, I will reconsider - but only after the merge
window. But I really think that, again, this is something you might
want to discuss with the Sphinx developers, then turn it into something
without hard-coded colors that will work with whatever theme people
might choose to build their docs with.
jon