PKZcMD sphinx_copybutton/__init__.py"""A small sphinx extension to add "copy" buttons to code blocks.""" import os __version__ = "0.2.2" def scb_static_path(app): static_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '_static')) app.config.html_static_path.append(static_path) github_url = 'https://cdn.rawgit.com/choldgraf/sphinx-copybutton/master/_static/' clipboard_js_url = "https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js" def setup(app): print('Adding copy buttons to code blocks...') # Add our static path app.connect('builder-inited', scb_static_path) # Add relevant code to headers app.add_stylesheet('copybutton.css') app.add_javascript(clipboard_js_url) app.add_javascript("copybutton.js") return {"version": __version__} PK`mPMT )sphinx_copybutton/_static/copy-button.svgPKRM. (sphinx_copybutton/_static/copybutton.css/* Copy buttons */ a.copybtn { position: absolute; top: 0; right: 0; margin: 5px; width: 1em; height: 1em; padding: 0 4px 2px; } div.highlight { position: relative; } /** * A minimal CSS-only tooltip copied from: * https://codepen.io/mildrenben/pen/rVBrpK * * To use, write HTML like the following: * *

Short

*/ .o-tooltip--left { position: relative; } .o-tooltip--left:after { opacity: 0; visibility: hidden; position: absolute; content: attr(data-tooltip); padding: 2px; top: 0; left: 0; background: grey; font-size: 1rem; color: white; white-space: nowrap; z-index: 2; border-radius: 2px; transform: translateX(-102%) translateY(0); transition: opacity 0.2s cubic-bezier(0.64, 0.09, 0.08, 1), transform 0.2s cubic-bezier(0.64, 0.09, 0.08, 1); } .o-tooltip--left:hover:after { display: block; opacity: 1; visibility: visible; transform: translateX(-100%) translateY(0); transition: opacity 0.2s cubic-bezier(0.64, 0.09, 0.08, 1), transform 0.2s cubic-bezier(0.64, 0.09, 0.08, 1); }PKRMuv'sphinx_copybutton/_static/copybutton.js/** * Set up copy/paste for code blocks */ const runWhenDOMLoaded = cb => { if (document.readyState != 'loading') { cb() } else if (document.addEventListener) { document.addEventListener('DOMContentLoaded', cb) } else { document.attachEvent('onreadystatechange', function() { if (document.readyState == 'complete') cb() }) } } const codeCellId = index => `codecell${index}` const clipboardButton = id => ` Copy to clipboard ` // Clears selected text since ClipboardJS will select the text when copying const clearSelection = () => { if (window.getSelection) { window.getSelection().removeAllRanges() } else if (document.selection) { document.selection.empty() } } // Changes tooltip text for two seconds, then changes it back const temporarilyChangeTooltip = (el, newText) => { const oldText = el.getAttribute('data-tooltip') el.setAttribute('data-tooltip', newText) setTimeout(() => el.setAttribute('data-tooltip', oldText), 2000) } const addCopyButtonToCodeCells = () => { // If ClipboardJS hasn't loaded, wait a bit and try again. This // happens because we load ClipboardJS asynchronously. if (window.ClipboardJS === undefined) { setTimeout(addCopyButtonToCodeCells, 250) return } const codeCells = document.querySelectorAll('div.highlight pre') codeCells.forEach((codeCell, index) => { const id = codeCellId(index) codeCell.setAttribute('id', id) codeCell.insertAdjacentHTML('afterend', clipboardButton(id)) }) const clipboard = new ClipboardJS('.copybtn') clipboard.on('success', event => { clearSelection() temporarilyChangeTooltip(event.trigger, 'Copied!') }) clipboard.on('error', event => { temporarilyChangeTooltip(event.trigger, 'Failed to copy') }) } runWhenDOMLoaded(addCopyButtonToCodeCells)PKhqLd//)sphinx_copybutton-0.2.2.dist-info/LICENSEMIT License Copyright (c) 2018 Chris Holdgraf Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!Hp!Qa'sphinx_copybutton-0.2.2.dist-info/WHEEL HM K-*ϳR03rOK-J,/RH,zd&Y)r$[)T&UD"PK!HXM^*sphinx_copybutton-0.2.2.dist-info/METADATATn8+&! PQmn-Pm-FPXbMIb?~8P/ș޼3!Eٟ輲k݊ ]ϬݰC^k~V} 7pZO?^D0[YѶy>Nل"k~+UcsATELw˷[u mշhQH=ļDUg7}h+`82mg 8ACGٳw+-zCuHIse'ޫBBQn=y9wUL;C 6z0V!4wl}^QЩ|?~__=e0n]Mb)SB~= A?s|#d8~oÉSp M>&o#c5faMTsX8l:IWi>UR4tu_JP.3t TWehyLVD.3cK5[ %ą{7^ʭ2\ΆNcK