Sphinx Copybutton

0.5.2 · active · verified Thu Apr 09

sphinx-copybutton is a Sphinx extension that adds a 'copy' button to each of your code cells in Sphinx documentation. It is currently at version 0.5.2, actively maintained, and releases generally align with bug fixes, minor enhancements, or updates to stay compatible with Sphinx itself.

Warnings

Install

Imports

Quickstart

To enable sphinx-copybutton, first install it using pip. Then, add 'sphinx_copybutton' to the `extensions` list within your Sphinx project's `conf.py` file. You can optionally configure its behavior, for example, by setting `copybutton_prompt_text` to exclude shell prompts from being copied.

# 1. Install the package:
# pip install sphinx-copybutton

# 2. Add 'sphinx_copybutton' to your conf.py extensions list:

# conf.py
import os
import sys

project = 'My Project'
copyright = '2023, Author'

extensions = [
    'sphinx.ext.autodoc',
    'sphinx_copybutton'
]

# Optional: Configure prompt text for copy button (example)
copybutton_prompt_text = "$ "
copybutton_prompt_is_regexp = False

view raw JSON →