Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude copy button from notebook cell numbers #1811

Merged

Conversation

gabalafou
Copy link
Collaborator

@gabalafou gabalafou commented May 13, 2024

Because of the way nbsphinx renders notebook cells and the way that Sphinx-copybutton targets code blocks, the line numbers next to notebook cells were getting the copy button, as the following screenshot shows:

copy button on line number

This PR changes the copy button selector to exclude the notebook cell line numbers.

Note: the default copy button selector is div.highlight pre

docs/conf.py Show resolved Hide resolved
Copy link

Coverage report

This PR does not seem to contain any modification to coverable code.

Copy link
Collaborator

@trallard trallard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!!! This looks good 🚀

@trallard trallard added the tag: component Issues or improvements associated with a given component in the theme label May 13, 2024
@trallard
Copy link
Collaborator

As I was about to merge, I thought, that since the change is in docs/conf.py (our documentation site configuration file this will only fix the issue for our docs.

Shall we add a note in our docs aimed at users so they know that if they are using notebooks to generate content like this they have to add this configuration to their own config.py file?

@gabalafou
Copy link
Collaborator Author

Oh, that's a good catch. Will need to give this a rethink

@gabalafou
Copy link
Collaborator Author

gabalafou commented May 14, 2024

In the short term, I decided to add a note to the docs for end users.

For the longer term, I will look into filing an issue or pull request with nbsphinx. For our end users, the ideal situation is for things to "just work" so they don't have to do extra config to make nbsphinx and Sphinx-copybutton play nicely together.

@trallard
Copy link
Collaborator

Agree! I think this short-term fix should suffice for now but ideally this will be something that just works for users long-term

@trallard trallard merged commit 810c6ad into pydata:main May 15, 2024
18 checks passed
ivanov pushed a commit to ivanov/pydata-sphinx-theme that referenced this pull request Jun 5, 2024
* Exclude copy button from notebook cell numbers

* Update docs/conf.py

* Add note in docs about Sphinx-copybutton and nbsphinx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag: component Issues or improvements associated with a given component in the theme
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants