-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-107024 Added copy button to code snippets in documentation #107037
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
base: main
Are you sure you want to change the base?
Conversation
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
We could add this to A |
@@ -22,6 +22,7 @@ | |||
'pyspecific', | |||
'sphinx.ext.coverage', | |||
'sphinx.ext.doctest', | |||
'sphinx_copybutton', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've been cautious about including third-party extensions, in case downstream redistributors haven't installed them. See the try/except block just below for sphinxext.opengraph.
All the others here are Sphinx builtin extensions, or our own custom ones.
@@ -36,3 +36,4 @@ sphinxcontrib-jsmath==1.0.1 | |||
sphinxcontrib-qthelp==1.0.3 | |||
sphinxcontrib-serializinghtml==1.1.5 | |||
urllib3==1.26.15 | |||
sphinx-copybutton<0.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is meant to be a generated list of pinned dependencies, see instructions at the top.
@@ -12,6 +12,7 @@ sphinx==6.2.0 | |||
blurb | |||
|
|||
sphinxext-opengraph==0.7.5 | |||
sphinx-copybutton<0.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the upper version limit?
Sure, I could do that if think that would be better |
I added sphinx-copybutton to documentation dependencies, which results in the following button in code snippets

If this is a right thing to do, then this requires a bit more work, as this right now copies the whole code block, but it could be changed through configuration.
It also overrides
>>>
toggle button where applicable. This has to be fixed or decided to be dropped and made so that copy button copies code without>>>
and output.📚 Documentation preview 📚: https://cpython-previews--107037.org.readthedocs.build/