Copy button not shown on some pages
Describe the bug
context When I go to https://docs.weblate.org/en/latest/api.html, the copy button is not present, while it works fine on other pages.
expectation I expected copy button to occur.
bug
But instead nothing happens. There are no error messages in the browser. The code is within div.highlight pre selector, so the copy button should be present.
problem
Looking at the code, it seems that window.ClipboardJS is not initialized for some reason and that blocks adding copy buttons:
https://github.com/executablebooks/sphinx-copybutton/blob/fae1f060b69625d3a1ce792b87410331f228110d/sphinx_copybutton/_static/copybutton.js_t#L129
I have no clue why it fails to load, but maybe it's time to drop this code and use
navigator.clipboard.writeText directly as described in https://github.com/executablebooks/sphinx-copybutton/issues/97?
Reproduce the bug
I currently have no clue how to reproduce this outside our documentation. The source code is here: https://github.com/WeblateOrg/weblate/tree/main/docs
List your environment
furo==2023.03.27
pygments==2.15.0
Sphinx==6.1.3
sphinx-copybutton==0.5.1
sphinx-jsonschema==1.19.1
sphinxcontrib-httpdomain==1.8.1
sphinxext-opengraph==0.8.1
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
@nijel out of curiosity (and thanks to 15 minutes free!) I made a build of Weblate's docs and, to my surprise, if you change the theme from furo to sphinx_rtd_theme, the copybuttons are shown. So in the end it might not be a bug in this extension, but some strange interaction with furo?
You're right, it works with some other theme. It also works with the Furo theme if I move the inclusion of the clipboard.min.js script somewhere in the middle of the document. I have no clue why it silently fails to initialize when it is at the bottom.
Instead of debugging obsolete code of clipboard.js, I decided to avoid it in https://github.com/executablebooks/sphinx-copybutton/pull/206