-
-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
DOC Add a button to copy code (#12512) #26666
DOC Add a button to copy code (#12512) #26666
Conversation
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.
I think this is a nice change. The copybutton sphinx extension is quite widely used as well.
One thing to try and find out from the archives: what was the thinking "back then" to add a button that hides the prompts, instead of having one that copies the text to the clipboard? Is it an accident of history or was there some specific thinking about this aproach (hide and then let the user copy themselves).
I believe the "hide prompts" button allowed for more controlled copy & paste user experience, because when you copy a block of code and paste it all, you might miss intermediate results. |
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.
Nice addition! LGTM as it is. Thanks @tuscland.
It would require to propose a change to sphinx-copybutton localized messages: |
It seems that this PR still has an issue. The copy button ignores lines that start by >>> train_scores, test_scores = validation_curve(
... logistic_regression, X, y, param_name=param_name, param_range=param_range
... ) ends up copying only >>> train_scores, test_scores = validation_curve( |
I'll try and make a PR to repair this or revert this change. |
I understand
@betatim as per the documentation, we could try this instead:
|
Reference Issues/PRs
Closes #12512.
What does this implement/fix? Explain your changes.
In the documentation, add a copy button to all code blocks.
When clicked, the text in the block is filtered in order to remove prompts (
>>>
) and output lines. Text without prompt is copied as-is.Any other comments?