Git Product home page Git Product logo

Comments (6)

choldgraf avatar choldgraf commented on July 17, 2024

oooh good question...hmm, currently no (the path to the SVG is hard-coded). But either:

  1. We could try adding a configuration to conf.py that would let the user set this path.
  2. We could check for a file called _static/copybutton.svg and if it exists use that file instead of the default one.
  3. We could provide documentation for how to change this button with Javascript after the site is loaded.

Any thoughts? :-)

from sphinx-copybutton.

thoo avatar thoo commented on July 17, 2024

@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.

choldgraf avatar choldgraf commented on July 17, 2024

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.

choldgraf avatar choldgraf commented on July 17, 2024

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:

  1. 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)
  1. 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.

thoo avatar thoo commented on July 17, 2024

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.

choldgraf avatar choldgraf commented on July 17, 2024

cool - I added these instructions here: #14

from sphinx-copybutton.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.