#1725·Gymnasium

[Proposal] Add copy buttons to documentation code blocks

Author: aroraanushriCreated Sep 28, 2026Updated Sep 28, 2026
Labelsenhancement

Proposal

Add a “Copy code” button in the top-right corner of every code block across the Gymnasium documentation, allowing readers to copy examples with one click.

Example pages:

Motivation

Following the tutorials often involves copying examples into an editor or notebook. Manually selecting longer snippets can lead to missed lines or accidentally selecting surrounding text, especially on mobile.

A consistent copy button would make it easier for beginners to run examples and experiment with Gymnasium while learning reinforcement learning.

Pitch

The button should:

  • Copy the entire code block while preserving indentation and line breaks.
  • Show brief “Copied!” feedback after a successful copy.
  • Exclude interactive prompts such as >>> and ... where applicable.
  • Be keyboard-accessible and have a descriptive accessible label.
  • Work in light and dark themes and on mobile without overlapping the code.

Ideally, this would be enabled globally through the documentation configuration or shared theme, avoiding changes to individual pages. I’d be happy to implement and test this. Would you prefer the contribution in this repository or in the shared documentation theme?

Alternatives

No response

Additional context

No response

Checklist

  • I have checked that there is no similar issue in the repo

Source: Farama-Foundation/Gymnasium