PK MOi sphinx_copybutton/__init__.py"""A small sphinx extension to add "copy" buttons to code blocks."""
import os
__version__ = "0.1.5"
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/'
fa_url = 'https://use.fontawesome.com/releases/v5.2.0/css/all.css'
boot_css_url = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
boot_js_url = "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
pop_js_url = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
clipboard_js_url = "https://cdn.jsdelivr.net/npm/clipboard@1/dist/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_stylesheet(fa_url)
app.add_stylesheet(boot_css_url)
app.add_javascript("copybutton.js")
app.add_javascript(clipboard_js_url)
app.add_javascript(pop_js_url)
app.add_javascript(boot_js_url)
PK
M;ے ( sphinx_copybutton/_static/copybutton.css/* Copy buttons */
button.copybtn {
padding: 0px 10px 0px 10px;
height: 100%;
max-height: 2em;
position: absolute;
right: -1px;
top: 0px;
background-color: rgb(238, 238, 238);
}
div.highlight .copybtn {
opacity: 1;
}
div.highlight {
position: relative;
}
PK
Mlߛ ' sphinx_copybutton/_static/copybutton.jsfunction addCopyButtonToCode(){
// get all code elements
var allCodeBlocksElements = $( "div.highlight pre" );
// For each element, do the following steps
allCodeBlocksElements.each(function(ii) {
// define a unique id for this element and add it
var currentId = "codeblock" + (ii + 1);
$(this).attr('id', currentId);
// create a button that's configured for clipboard.js
// point it to the text that's in this code block
// add the button just after the text in the code block w/ jquery
var clipButton = '';
$(this).after(clipButton);
});
// Tooltip functions
function setTooltip(btn, message) {
$(btn).tooltip('hide')
.attr('data-original-title', message)
.tooltip('show');
}
function hideTooltip(btn) {
setTimeout(function() {
$(btn).tooltip('hide');
}, 800);
}
$('.btn').tooltip({
trigger: 'click',
placement: 'bottom'
});
// tell clipboard.js to look for clicks that match this query
var clipboard = new Clipboard('.btn');
function clearSelection() {
if (window.getSelection) {window.getSelection().removeAllRanges();}
else if (document.selection) {document.selection.empty();}
}
clipboard.on('success', function(e) {
clearSelection();
setTooltip(e.trigger, 'Copied!');
hideTooltip(e.trigger);
});
clipboard.on('error', function(e) {
setTooltip(e.trigger, 'Failed!');
hideTooltip(e.trigger);
});
}
$(document).ready(function () {
// Once the DOM is loaded for the page, attach clipboard buttons
addCopyButtonToCode();
});
PK hLd/ / ) sphinx_copybutton-0.1.5.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!Q a ' sphinx_copybutton-0.1.5.dist-info/WHEELHM
K-*ϳR03rOK-J,/RH,zd&Y)r$[)T&UD" PK !H{} * sphinx_copybutton-0.1.5.dist-info/METADATAS[O0~8D1i/&*e:4!]MؖPgIKs.8*r#/~(К
>s2筪 볰_v1ZCE9D徯`Z:@Fer!D\J8ǰE 9*TV%Uulbt*c-m)eP$Է<ɤL.wpZ=◥kUOȅ
£Ix1&y}zLdu-Ɛ!
U LE}=KR"۫
.3`99v^I/uo,~>vLN-;iE,Q5'zMOہp6`̡c!1\!Bfzy`u=|XVg=6,[1DJҚ>#PJt*}hԠ0
ܲIp<0v
4E%%1jBO