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

Copy button for snippets #7

Closed
MaxHalford opened this issue Oct 4, 2019 · 9 comments
Closed

Copy button for snippets #7

MaxHalford opened this issue Oct 4, 2019 · 9 comments
Labels
enhancement New feature or request

Comments

@MaxHalford
Copy link

Hey. Not sure this is in scope or not. Maybe it would be nice to add a copy button to each snippet, like what is done here. Maybe be using clipboard.js?

@bashtage
Copy link
Owner

bashtage commented Oct 7, 2019

I'm not sure this is simple since it isn't easy to ensure that an appropriate class is added to snippets.

I think something would need to be added to code-block,

https://www.sphinx-doc.org/es/master/usage/restructuredtext/directives.html#directive-code-block

like the option to add a user class.

Perhaps rst-class would be enough? Although this would require changing code and couldn't just be added using a conf option.

@bashtage bashtage added the enhancement New feature or request label Oct 7, 2019
@mgeier
Copy link
Contributor

mgeier commented Dec 5, 2019

FYI: there is https://github.com/choldgraf/sphinx-copybutton

I don't know if it works with this theme, though.

@bashtage
Copy link
Owner

bashtage commented Dec 5, 2019

Would be good to add it. I was thinking it would be configurable. If sphinx-copybutton works, then I suppose could just suggest that rather than rolling a hone-grown solution.

@carrascomj
Copy link

carrascomj commented Dec 19, 2019

It works, although it has got a slight glitch with the jupyter notebook's codeblocks (you can see that it has one extra button on the left of every codeblock here.

@mgeier
Copy link
Contributor

mgeier commented Dec 19, 2019

This is actively being worked on in spatialaudio/nbsphinx#349

Please leave your feedback there!

@mgeier
Copy link
Contributor

mgeier commented Jan 28, 2020

I've just released nbsphinx version 0.5.1 which should fix the glitches with sphinx-copybutton.

Here's how Jupyter notebooks look with the sphinx-material theme and with sphinx-copybutton enabled: https://nbsphinx.readthedocs.io/en/material-theme/code-cells.html.

@carrascomj
Copy link

carrascomj commented Jan 28, 2020

Thanks! I confirm It works like a charm: https://dynamic-fba.readthedocs.io/en/latest/example1.html

@bashtage
Copy link
Owner

Looks great!

@MaxHalford
Copy link
Author

Just set it up, looks really nice!

mithro referenced this issue in f4pga/sphinx_f4pga_theme Feb 21, 2021
* Show underline when hovering over links
* Change foreground color to have stronger contrast as per #7
* Remove extraneous padding and nicely align left side with right side of
footer
* Add link to LICENSE in GitHub repo

Signed-off-by: Daniel Lim Wee Soong <weesoong.lim@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants