freshcrate
Home > Frameworks > sphinx-copybutton

sphinx-copybutton

Add a copy button to each of your code cells.

Description

# sphinx-copybutton [![PyPI](https://img.shields.io/pypi/v/sphinx-copybutton.svg)](https://pypi.org/project/sphinx_copybutton/) | [![Conda Version](https://img.shields.io/conda/vn/conda-forge/sphinx-copybutton.svg)](https://anaconda.org/conda-forge/sphinx-copybutton) | [![Documentation](https://readthedocs.org/projects/sphinx-copybutton/badge/?version=latest)](https://sphinx-copybutton.readthedocs.io/en/latest/?badge=latest) A small sphinx extension to add a "copy" button to code blocks. See [the sphinx-copybutton documentation](https://sphinx-copybutton.readthedocs.io/en/latest/) for more details! ![Copy Button Demo](https://user-images.githubusercontent.com/1839645/150200219-73663c59-08fd-4185-b157-62f3769c02ac.gif) ## Installation You can install `sphinx-copybutton` with `pip`: ```bash pip install sphinx-copybutton ``` Or with `conda` via `conda-forge`: ```bash conda install -c conda-forge sphinx-copybutton ``` ## Usage In your `conf.py` configuration file, add `sphinx_copybutton` to your extensions list. E.g.: ```python extensions = [ ... 'sphinx_copybutton' ... ] ``` When you build your site, your code blocks should now have little copy buttons to their right. Clicking the button will copy the code inside! ## Customization If you'd like to customize the look of the copy buttons, you can over-write any of the CSS rules specified in the Sphinx-CopyButton CSS file ([link](sphinx_copybutton/_static/copybutton.css)) ## Development Development should principally adhere to the [EBP Developer Conventions](https://github.com/executablebooks/.github/blob/master/CONTRIBUTING.md) Sphinx-Copybutton is [hosted on the pypi repository](https://pypi.org/project/sphinx-copybutton/). After a release - following the [EBP release instructions](https://github.com/executablebooks/.github/blob/master/CONTRIBUTING.md#releases-and-change-logs) - confirm that the new version of Sphinx-Copybutton [is posted to pypi](https://pypi.org/project/sphinx-copybutton/). ## Acknowledgements Many thanks to the excellent [clipboard.js library](https://clipboardjs.com/) for the lightweight javascript code that powers the copy button!

Release History

VersionChangesUrgencyDate
0.5.2Imported from PyPI (0.5.2)Low4/21/2026
v0.5.2## v0.5.2 - 2022-11-15 ([full changelog](https://github.com/executablebooks/sphinx-copybutton/compare/v0.5.1...v0.5.2)) - BUG: Don't exclude `.gp` class by default. This made excluding prompts more automatic, but broke the existing pattern-based prompt exclusion. [#188](https://github.com/executablebooks/sphinx-copybutton/pull/188) ([@rkdarst](https://github.com/rkdarst)) - MAINT: Add Sphinx Extension classifier (#189) [#189](https://github.com/executablebooks/sphinx-copybutton/pull/Low4/14/2023
v0.5.1([full changelog](https://github.com/executablebooks/sphinx-copybutton/compare/v0.5.0...e529aa0c7c0bf6ad880904f7a8876f33040e5c09)) - ENH: Unselectable text is now also not highlighted when you manually highlight a code cell. Exclude unselectable text from being copied (update) [#178](https://github.com/executablebooks/sphinx-copybutton/pull/178) ([@rkdarst](https://github.com/rkdarst)) - ENH: After copying, the copybutton will disappear _before_ the icon changes back if you are no longer hovLow11/15/2022
v0.5.0This release updates the copy button design and behavior to match GitHub's design guide and button behavior. It also directly inserts the SVG instead of linking it via an `<img>` tag so that it can be styled more flexibly. ### Enhancements - ENH: Directly add SVG instead of linking via IMG [#161](https://github.com/executablebooks/sphinx-copybutton/pull/161) ([@choldgraf](https://github.com/choldgraf)) - ENH: Update copybutton image to match GitHub [#155](https://github.com/executablebookLow2/6/2022
v0.4.0Release v0.4.0Low7/3/2021
v0.3.3Minor release for fix #132 Low6/13/2021
v0.3.2See [CHANGELOG.md](https://github.com/executablebooks/sphinx-copybutton/blob/master/CHANGELOG.md#032---2021-06-11) for new enhancements!Low6/11/2021
v0.3.1See [CHANGELOG.md](https://github.com/executablebooks/sphinx-copybutton/blob/master/CHANGELOG.md)Low11/2/2020
v0.3.0## 0.3.0 - 2020-07-25 ### Breaking - Copy raw regex string to JS template, thanks to @s-weigand. This fixes the way that the `copybutton_prompt_text` value is injected into `copybutton.js_t` (as discussed in #86). The raw string formatting means that backslashes are now propagated correctly and removes the need for "double escaping". Users will need to update their `copybutton_prompt_text` string accordingly. ### Changed - Upgraded [lodash](https://github.com/lodash/lodash) Low7/25/2020
v0.2.12Release v0.2.12Low6/17/2020
v0.2.11# 0.2.8...v0.2.11 ([full changelog](https://github.com/ExecutableBookProject/sphinx-copybutton/compare/0.2.8...v0.2.11)) ## Merged PRs * fixing workflow [#78](https://github.com/ExecutableBookProject/sphinx-copybutton/pull/78) ([@choldgraf](https://github.com/choldgraf)) * github action [#77](https://github.com/ExecutableBookProject/sphinx-copybutton/pull/77) ([@choldgraf](https://github.com/choldgraf)) * sphinx copybutton info [#75](https://github.com/ExecutableBookProject/sphinx-copybLow4/23/2020
0.2.8# v0.2.7@{2019-12-02}...v0.2.8@{2020-01-03} ([full changelog](https://github.com/choldgraf/sphinx-copybutton/compare/c64ada61571bd77f4634fd79efb7c5df69d3fc1a...9283d9ccae64c53b749a7af72382e4a1c02c2916)) ## Overview This is a minor version bump with two main changes: 1. sphinx-copybutton should now work as a self-contained package, meaning that it can be run offline without requiring an external CDN for the necessary javascript 2. it now supports *skipping* some text at the beginning Low1/3/2020

Dependencies & License Audit

Loading dependencies...

Similar Packages

pre-commitA framework for managing and maintaining multi-language pre-commit hooks.v4.6.0
azure-core-tracing-opentelemetryMicrosoft Azure Azure Core OpenTelemetry plugin Library for Pythonazure-template_0.1.0b6187637
spdx-toolsSPDX parser and tools.0.8.5
lacesDjango components that know how to render themselves.0.1.2
django-tasksA backport of Django's built in Tasks framework0.12.0