Skip to content

Commit

Permalink
v1.10.1.0 latest documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhassell committed Apr 26, 2023
1 parent c813898 commit f373d10
Show file tree
Hide file tree
Showing 2,007 changed files with 40,078 additions and 37,420 deletions.
304 changes: 161 additions & 143 deletions docs/Changelog.html

Large diffs are not rendered by default.

Binary file modified docs/_downloads/cfdm_tutorial_files.zip
Binary file not shown.
5 changes: 2 additions & 3 deletions docs/_downloads/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,8 @@
import netCDF4
nc = netCDF4.Dataset('file.nc', 'r')
v = nc.variables['ta']
netcdf_array = cfdm.NetCDFArray(filename='file.nc', ncvar='ta',
dtype=v.dtype, ndim=v.ndim,
shape=v.shape, size=v.size)
netcdf_array = cfdm.NetCDFArray(filename='file.nc', address='ta',
dtype=v.dtype, shape=v.shape)
data_disk = cfdm.Data(netcdf_array)
numpy_array = v[...]
data_memory = cfdm.Data(numpy_array)
Expand Down
4 changes: 3 additions & 1 deletion docs/_static/alabaster.css
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,9 @@ table.footnote td {
}

dl {
margin: 0;
margin-left: 0;
margin-right: 0;
margin-top: 0;
padding: 0;
}

Expand Down
2 changes: 1 addition & 1 deletion docs/_static/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
* :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
Expand Down
8 changes: 4 additions & 4 deletions docs/_static/clipboard.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/_static/copy-button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 46 additions & 19 deletions docs/_static/copybutton.css
Original file line number Diff line number Diff line change
@@ -1,30 +1,51 @@
/* Copy buttons */
a.copybtn {
button.copybtn {
position: absolute;
top: .2em;
right: .2em;
width: 1em;
height: 1em;
opacity: .3;
transition: opacity 0.5s;
border: none;
display: flex;
top: .3em;
right: .3em;
width: 1.7em;
height: 1.7em;
opacity: 0;
transition: opacity 0.3s, border .3s, background-color .3s;
user-select: none;
padding: 0;
border: none;
outline: none;
border-radius: 0.4em;
/* The colors that GitHub uses */
border: #1b1f2426 1px solid;
background-color: #f6f8fa;
color: #57606a;
}

button.copybtn.success {
border-color: #22863a;
color: #22863a;
}

button.copybtn svg {
stroke: currentColor;
width: 1.5em;
height: 1.5em;
padding: 0.1em;
}

div.highlight {
position: relative;
}

a.copybtn > img {
vertical-align: top;
margin: 0;
top: 0;
left: 0;
position: absolute;
/* Show the copybutton */
.highlight:hover button.copybtn, button.copybtn.success {
opacity: 1;
}

.highlight:hover .copybtn {
opacity: 1;
.highlight button.copybtn:hover {
background-color: rgb(235, 235, 235);
}

.highlight button.copybtn:active {
background-color: rgb(187, 187, 187);
}

/**
Expand All @@ -44,11 +65,10 @@ a.copybtn > img {
visibility: hidden;
position: absolute;
content: attr(data-tooltip);
padding: 2px;
top: 0;
padding: .2em;
font-size: .8em;
left: -.2em;
background: grey;
font-size: 1rem;
color: white;
white-space: nowrap;
z-index: 2;
Expand All @@ -65,3 +85,10 @@ a.copybtn > img {
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);
transition-delay: .5s;
}

/* By default the copy button shouldn't show up when printing a page */
@media print {
button.copybtn {
display: none;
}
}
139 changes: 117 additions & 22 deletions docs/_static/copybutton.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,30 @@ const messages = {
'copy_to_clipboard': 'In die Zwischenablage kopieren',
'copy_success': 'Kopiert!',
'copy_failure': 'Fehler beim Kopieren',
},
'fr' : {
'copy': 'Copier',
'copy_to_clipboard': 'Copié dans le presse-papier',
'copy_success': 'Copié !',
'copy_failure': 'Échec de la copie',
},
'ru': {
'copy': 'Скопировать',
'copy_to_clipboard': 'Скопировать в буфер',
'copy_success': 'Скопировано!',
'copy_failure': 'Не удалось скопировать',
},
'zh-CN': {
'copy': '复制',
'copy_to_clipboard': '复制到剪贴板',
'copy_success': '复制成功!',
'copy_failure': '复制失败',
},
'it' : {
'copy': 'Copiare',
'copy_to_clipboard': 'Copiato negli appunti',
'copy_success': 'Copiato!',
'copy_failure': 'Errore durante la copia',
}
}

Expand All @@ -26,6 +50,31 @@ if( document.documentElement.lang !== undefined
locale = document.documentElement.lang
}

let doc_url_root = DOCUMENTATION_OPTIONS.URL_ROOT;
if (doc_url_root == '#') {
doc_url_root = '';
}

/**
* SVG files for our copy buttons
*/
let iconCheck = `<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-check" width="44" height="44" viewBox="0 0 24 24" stroke-width="2" stroke="#22863a" fill="none" stroke-linecap="round" stroke-linejoin="round">
<title>${messages[locale]['copy_success']}</title>
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M5 12l5 5l10 -10" />
</svg>`

// If the user specified their own SVG use that, otherwise use the default
let iconCopy = ``;
if (!iconCopy) {
iconCopy = `<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-copy" width="44" height="44" viewBox="0 0 24 24" stroke-width="1.5" stroke="#000000" fill="none" stroke-linecap="round" stroke-linejoin="round">
<title>${messages[locale]['copy_to_clipboard']}</title>
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<rect x="8" y="8" width="12" height="12" rx="2" />
<path d="M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2" />
</svg>`
}

/**
* Set up copy/paste for code blocks
*/
Expand Down Expand Up @@ -53,11 +102,25 @@ const clearSelection = () => {
}
}

// Changes tooltip text for two seconds, then changes it back
const temporarilyChangeTooltip = (el, newText) => {
const oldText = el.getAttribute('data-tooltip')
// Changes tooltip text for a moment, then changes it back
// We want the timeout of our `success` class to be a bit shorter than the
// tooltip and icon change, so that we can hide the icon before changing back.
var timeoutIcon = 2000;
var timeoutSuccessClass = 1500;

const temporarilyChangeTooltip = (el, oldText, newText) => {
el.setAttribute('data-tooltip', newText)
setTimeout(() => el.setAttribute('data-tooltip', oldText), 2000)
el.classList.add('success')
// Remove success a little bit sooner than we change the tooltip
// So that we can use CSS to hide the copybutton first
setTimeout(() => el.classList.remove('success'), timeoutSuccessClass)
setTimeout(() => el.setAttribute('data-tooltip', oldText), timeoutIcon)
}

// Changes the copy button icon for two seconds, then changes it back
const temporarilyChangeIcon = (el) => {
el.innerHTML = iconCheck;
setTimeout(() => {el.innerHTML = iconCopy}, timeoutIcon)
}

const addCopyButtonToCodeCells = () => {
Expand All @@ -69,30 +132,49 @@ const addCopyButtonToCodeCells = () => {
}

// Add copybuttons to all of our code cells
const codeCells = document.querySelectorAll('div.highlight pre')
const COPYBUTTON_SELECTOR = 'div.highlight pre';
const codeCells = document.querySelectorAll(COPYBUTTON_SELECTOR)
codeCells.forEach((codeCell, index) => {
const id = codeCellId(index)
codeCell.setAttribute('id', id)
const pre_bg = getComputedStyle(codeCell).backgroundColor;

const clipboardButton = id =>
`<a class="copybtn o-tooltip--left" style="background-color: ${pre_bg}" data-tooltip="${messages[locale]['copy']}" data-clipboard-target="#${id}">
<img src="${DOCUMENTATION_OPTIONS.URL_ROOT}_static/copy-button.svg" alt="${messages[locale]['copy_to_clipboard']}">
</a>`
`<button class="copybtn o-tooltip--left" data-tooltip="${messages[locale]['copy']}" data-clipboard-target="#${id}">
${iconCopy}
</button>`
codeCell.insertAdjacentHTML('afterend', clipboardButton(id))
})

function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}

/**
* Removes excluded text from a Node.
*
* @param {Node} target Node to filter.
* @param {string} exclude CSS selector of nodes to exclude.
* @returns {DOMString} Text from `target` with text removed.
*/
function filterText(target, exclude) {
const clone = target.cloneNode(true); // clone as to not modify the live DOM
if (exclude) {
// remove excluded nodes
clone.querySelectorAll(exclude).forEach(node => node.remove());
}
return clone.innerText;
}

// Callback when a copy button is clicked. Will be passed the node that was clicked
// should then grab the text and replace pieces of text that shouldn't be used in output
function formatCopyText(textContent, copybuttonPromptText, isRegexp = false, onlyCopyPromptLines = true, removePrompts = true) {

function formatCopyText(textContent, copybuttonPromptText, isRegexp = false, onlyCopyPromptLines = true, removePrompts = true, copyEmptyLines = true, lineContinuationChar = "", hereDocDelim = "") {
var regexp;
var match;

// Do we check for line continuation characters and "HERE-documents"?
var useLineCont = !!lineContinuationChar
var useHereDoc = !!hereDocDelim

// create regexp to capture prompt and remaining line
if (isRegexp) {
regexp = new RegExp('^(' + copybuttonPromptText + ')(.*)')
Expand All @@ -102,24 +184,31 @@ function formatCopyText(textContent, copybuttonPromptText, isRegexp = false, onl

const outputLines = [];
var promptFound = false;
var gotLineCont = false;
var gotHereDoc = false;
const lineGotPrompt = [];
for (const line of textContent.split('\n')) {
match = line.match(regexp)
if (match) {
promptFound = true
if (removePrompts) {
if (match || gotLineCont || gotHereDoc) {
promptFound = regexp.test(line)
lineGotPrompt.push(promptFound)
if (removePrompts && promptFound) {
outputLines.push(match[2])
} else {
outputLines.push(line)
}
} else {
if (!onlyCopyPromptLines) {
outputLines.push(line)
}
gotLineCont = line.endsWith(lineContinuationChar) & useLineCont
if (line.includes(hereDocDelim) & useHereDoc)
gotHereDoc = !gotHereDoc
} else if (!onlyCopyPromptLines) {
outputLines.push(line)
} else if (copyEmptyLines && line.trim() === '') {
outputLines.push(line)
}
}

// If no lines with the prompt were found then just use original lines
if (promptFound) {
if (lineGotPrompt.some(v => v === true)) {
textContent = outputLines.join('\n');
}

Expand All @@ -133,7 +222,12 @@ function formatCopyText(textContent, copybuttonPromptText, isRegexp = false, onl

var copyTargetText = (trigger) => {
var target = document.querySelector(trigger.attributes['data-clipboard-target'].value);
return formatCopyText(target.innerText, '$ ', false, true, true)

// get filtered text
let exclude = '.linenos, .gp';

let text = filterText(target, exclude);
return formatCopyText(text, '$ ', false, true, true, true, '', '')
}

// Initialize with a callback so we can modify the text before copy
Expand All @@ -142,11 +236,12 @@ var copyTargetText = (trigger) => {
// Update UI with error/success messages
clipboard.on('success', event => {
clearSelection()
temporarilyChangeTooltip(event.trigger, messages[locale]['copy_success'])
temporarilyChangeTooltip(event.trigger, messages[locale]['copy'], messages[locale]['copy_success'])
temporarilyChangeIcon(event.trigger)
})

clipboard.on('error', event => {
temporarilyChangeTooltip(event.trigger, messages[locale]['copy_failure'])
temporarilyChangeTooltip(event.trigger, messages[locale]['copy'], messages[locale]['copy_failure'])
})
}

Expand Down
Loading

0 comments on commit f373d10

Please sign in to comment.