Comments (6)
oooh good question...hmm, currently no (the path to the SVG is hard-coded). But either:
- We could try adding a configuration to
conf.py
that would let the user set this path. - We could check for a file called
_static/copybutton.svg
and if it exists use that file instead of the default one. - We could provide documentation for how to change this button with Javascript after the site is loaded.
Any thoughts? :-)
from sphinx-copybutton.
@choldgraf Thanks for the quick reply. It would we nice to have an option to configure in conf.py
. I submitted PR for scikit-image
to add a copybutton using your extension. Hopefully, more python machine learning communities use your extensions. Tensorflow already had a copy button. 👍
from sphinx-copybutton.
ok cool, lemme see if I can figure this one out...shouldn't be too hard (or PRs are welcome as well!)
from sphinx-copybutton.
hmmm, I looked into it a little bit, and I can't figure out how to set a javascript variable using a configuration in conf.py
...sphinx extensions is such a mystery to me :-P
could you try a hacky solution to this first? :-)
If you did these two things:
- included your own javascript with the site (e.g., in
_static/js/custom.js
) like the following example (which loads a random other image instead of the default copy button image):
const updateCopyButtonImages = () => {
const copybuttonimages = document.querySelectorAll('a.copybtn img')
copybuttonimages.forEach((img, index) => {
img.setAttribute('src', 'http://www.clker.com/cliparts/2/2/8/6/11949945221692172998copy.svg.hi.png')
})
}
runWhenDOMLoaded(updateCopyButtonImages)
- Add that stylesheet to your
conf.py
configuration like so:
def setup(app):
app.add_javascript('js/custom.js');
then it should update the images on site load. Does that work for you?
from sphinx-copybutton.
Thanks. I think it should work. I will close the issue for now. If I run into issues, I will get back to you. :) Thanks for the help.
from sphinx-copybutton.
cool - I added these instructions here: #14
from sphinx-copybutton.
Related Issues (20)
- Convert documentation into MyST Markdown
- Update the copybutton image to match GitHub's copybutton style
- Modularize our documentation a bit HOT 1
- Copy button stays put sometimes when other objects shrink its container
- Copy button does not show up for productionlist HOT 1
- issue to store media HOT 1
- Post message after all copy buttons added HOT 3
- Build failed for config doc when importing an extension sphinx_copybutton HOT 4
- Failed build in RTD for extension sphinx-copybutton
- Copybutton disappears too quickly if you click copy then move the cursor off the code cell
- Conflict between regex exclusion/prompt selection and copybutton_exclude HOT 12
- Add Trailing New Line to Clipboard Option HOT 1
- Blank Lines Stripped from code
- Use only one tooltip HOT 2
- newline ignored when using emphasize-lines HOT 1
- Copy button not shown on some pages HOT 3
- Example Not Functional HOT 2
- Add expand button for some block elements HOT 1
- Stripping ellipsis HOT 1
- URL to copy-button.svg is incorrect because DOCUMENTATION_OPTIONS.URL_ROOT is undefined HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sphinx-copybutton.