From cf0de0c543855b0f8bd0b0a65a12aa84573711f9 Mon Sep 17 00:00:00 2001 From: Chris Holdgraf Date: Tue, 18 Jan 2022 19:24:13 -0800 Subject: [PATCH 1/4] ENH: Update copybutton image to match GitHub --- sphinx_copybutton/_static/copy-button.svg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sphinx_copybutton/_static/copy-button.svg b/sphinx_copybutton/_static/copy-button.svg index b888a20..e67ae3d 100644 --- a/sphinx_copybutton/_static/copy-button.svg +++ b/sphinx_copybutton/_static/copy-button.svg @@ -1,5 +1,5 @@ - + - - + + From 5e358adcfc5c9a4c442eed4b67359bc8e92a9be8 Mon Sep 17 00:00:00 2001 From: Chris Holdgraf Date: Tue, 18 Jan 2022 20:24:48 -0800 Subject: [PATCH 2/4] Update copybutton img --- sphinx_copybutton/_static/copy-button.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx_copybutton/_static/copy-button.svg b/sphinx_copybutton/_static/copy-button.svg index e67ae3d..9c074da 100644 --- a/sphinx_copybutton/_static/copy-button.svg +++ b/sphinx_copybutton/_static/copy-button.svg @@ -1,4 +1,4 @@ - + From cc6d3ed98fdb093cf58fddd0d4d2aa4b9f0c08fd Mon Sep 17 00:00:00 2001 From: Chris Holdgraf Date: Wed, 19 Jan 2022 10:28:15 -0800 Subject: [PATCH 3/4] Add docs for manual icon --- docs/_static/clipboard.svg | 5 +++++ docs/conf.py | 2 +- docs/index.rst | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 docs/_static/clipboard.svg diff --git a/docs/_static/clipboard.svg b/docs/_static/clipboard.svg new file mode 100644 index 0000000..b888a20 --- /dev/null +++ b/docs/_static/clipboard.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/docs/conf.py b/docs/conf.py index c53e6c2..43d5d07 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -108,7 +108,7 @@ # Switches for testing but shouldn't be activated in the live docs # copybutton_only_copy_prompt_lines = False # copybutton_remove_prompts = False -# copybutton_image_path = "test/TEST_COPYBUTTON.png" +# copybutton_image_path = "clipboard.svg" # copybutton_selector = "div" diff --git a/docs/index.rst b/docs/index.rst index 99c2ad4..3df2fc8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -352,6 +352,33 @@ To use a different image for your copy buttons, do the following: path to your image file, **relative to** ``_static/``. +For example, if you wanted to use a **clipboard icon** instead of the default copy button icon, do the following: + +1. Copy the ``Clipboard Icon SVG`` from `the Tabular icons pack `_. + Here is the SVG for reference: + + .. code-block:: svg + + + + + + + +2. Create a file at ``_static/clipboard.svg`` from your documentation root. + Paste in the SVG above into that file. + +3. Ensure that your ``_static`` folder is added to your ``html_static_paths`` configuration in Sphinx. +4. Configure ``sphinx_copybutton`` to use this icon instead, via the following configuration: + + .. code-block:: python + + # Note that we do not include `_static` + # because the path should be *relative* to the static folder. + copybutton_image_path = "clipboard.svg" + +When you re-build your documentation, you should see this new icon in your copy buttons. + Configure the CSS selector used to add copy buttons ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From d6022af0f79caf595d9b3c3b35de09ce8c8c84e3 Mon Sep 17 00:00:00 2001 From: Chris Holdgraf Date: Wed, 19 Jan 2022 10:49:35 -0800 Subject: [PATCH 4/4] Fix docs --- docs/index.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index 3df2fc8..6b5f6c3 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -411,9 +411,11 @@ For example, to make the copy button visible by default (not just when a code ce 2. Add the following rule to it: .. code-block:: css + button.copybtn { opacity: 1; } + 3. Add the CSS file to Sphinx by ensuring that the following configuration exists in your ``conf.py`` file (see `the Sphinx documentation for more details `_): .. code-block:: python