Skip to content

Commit

Permalink
Exclude copy button from notebook cell numbers (#1811)
Browse files Browse the repository at this point in the history
* Exclude copy button from notebook cell numbers

* Update docs/conf.py

* Add note in docs about Sphinx-copybutton and nbsphinx
  • Loading branch information
gabalafou authored May 15, 2024
1 parent 64fbfef commit 810c6ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
togglebutton_hint = str(_("Click to expand"))
togglebutton_hint_hide = str(_("Click to collapse"))

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

# -- Options for HTML output -------------------------------------------------

Expand Down
11 changes: 11 additions & 0 deletions docs/user_guide/web-components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,17 @@ You can see it in action by hovering over the code cell below:
print("A copybutton in the top-right!")
.. admonition:: nbsphinx

If your documentation site uses both nbsphinx and Sphinx-copybutton, you
will want to add the following line to your ``conf.py`` file to prevent the
copy button from appearing on top of notebook cell numbers:

.. code-block:: python
:caption: conf.py
copybutton_selector = ":not(.prompt) > div.highlight pre"
Toggle buttons
==============

Expand Down

0 comments on commit 810c6ad

Please sign in to comment.