Skip to content

Commit 810c6ad

Browse files
authored
Exclude copy button from notebook cell numbers (#1811)
* Exclude copy button from notebook cell numbers * Update docs/conf.py * Add note in docs about Sphinx-copybutton and nbsphinx
1 parent 64fbfef commit 810c6ad

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

docs/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@
9494
togglebutton_hint = str(_("Click to expand"))
9595
togglebutton_hint_hide = str(_("Click to collapse"))
9696

97+
# -- Sphinx-copybutton options ---------------------------------------------
98+
# Exclude copy button from appearing over notebook cell numbers by using :not()
99+
# The default copybutton selector is `div.highlight pre`
100+
# https://github.com/executablebooks/sphinx-copybutton/blob/master/sphinx_copybutton/__init__.py#L82
101+
copybutton_selector = ":not(.prompt) > div.highlight pre"
97102

98103
# -- Options for HTML output -------------------------------------------------
99104

docs/user_guide/web-components.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,17 @@ You can see it in action by hovering over the code cell below:
263263
264264
print("A copybutton in the top-right!")
265265
266+
.. admonition:: nbsphinx
267+
268+
If your documentation site uses both nbsphinx and Sphinx-copybutton, you
269+
will want to add the following line to your ``conf.py`` file to prevent the
270+
copy button from appearing on top of notebook cell numbers:
271+
272+
.. code-block:: python
273+
:caption: conf.py
274+
275+
copybutton_selector = ":not(.prompt) > div.highlight pre"
276+
266277
Toggle buttons
267278
==============
268279

0 commit comments

Comments
 (0)