-
Notifications
You must be signed in to change notification settings - Fork 1
/
CONTRIBUTING.html
565 lines (545 loc) · 30 KB
/
CONTRIBUTING.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.4.555">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>contributing</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
</style>
<script src="CONTRIBUTING_files/libs/clipboard/clipboard.min.js"></script>
<script src="CONTRIBUTING_files/libs/quarto-html/quarto.js"></script>
<script src="CONTRIBUTING_files/libs/quarto-html/popper.min.js"></script>
<script src="CONTRIBUTING_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="CONTRIBUTING_files/libs/quarto-html/anchor.min.js"></script>
<link href="CONTRIBUTING_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="CONTRIBUTING_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="CONTRIBUTING_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="CONTRIBUTING_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="CONTRIBUTING_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
</head>
<body class="fullcontent">
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<main class="content" id="quarto-document-content">
<section id="cloud-span-contribution-guide" class="level1">
<h1>Cloud-SPAN Contribution Guide</h1>
<p>Hi there! Are you interested in contributing content to the Cloud-SPAN project?</p>
<p>You’re in the right place!</p>
<section id="joining-the-community" class="level2">
<h2 class="anchored" data-anchor-id="joining-the-community">Joining the Community</h2>
<p>We welcome all contributions, big or small, and we’d love to welcome you into our community. We are open to people of all backgrounds with an interest in ’omics and/or cloud computing.</p>
<p>Please be aware of our <a href="%22https://github.com/Cloud-SPAN/CloudSPAN-handbook-bookdown/blob/master/CODE_OF_CONDUCT.md%22">Code of Conduct</a> which must be respected at all times during Cloud-SPAN events, courses and online interactions.</p>
</section>
<section id="cloud-span-course-structure" class="level2">
<h2 class="anchored" data-anchor-id="cloud-span-course-structure">Cloud-SPAN Course Structure</h2>
<p>If you’re thinking of making a contribution, it will be useful for you to understand how we structure our courses and repositories. Currently some of our courses are hosted in a ‘Carpentries’ format and some are hosted on Quarto websites - but they’re all available to contribute to via GitHub.</p>
<section id="for-carpentries-style-courses-prenomics-genomics-create-your-own-aws-instance" class="level3">
<h3 class="anchored" data-anchor-id="for-carpentries-style-courses-prenomics-genomics-create-your-own-aws-instance">For ‘Carpentries’ style courses (<a href="https://cloud-span.github.io/prenomics00-intro/">Prenomics</a>, <a href="https://cloud-span.github.io/00genomics/">Genomics</a>, <a href="https://cloud-span.github.io/create-aws-instance-0-overview/">Create Your Own AWS Instance</a>)</h3>
<ul>
<li>Each course is divided into several “lessons”. Each lesson contains several “episodes”.</li>
<li>Each lesson gets its own repository, which is named using the format <strong>course-name</strong> + <strong>number</strong> + <strong>lesson-name</strong>. For example, the first lesson of our Genomics course (<em>Project Management for Cloud Genomics</em>) is named <strong>genomics01-proj-mngt-cloud-genomics</strong>.
<ul>
<li>Be aware that repo-00 of each course is reserved for the course introduction/overview.</li>
<li>This means that the first lesson of each course is labelled as 01, the second as 02 and so on.</li>
</ul></li>
<li>Each lesson has a homepage which contains introductory information and an overview of the topics included.This page is stored under the name <code>index.md</code>.</li>
<li>Episodes are stored as markdown files inside the relevant lesson repository under a folder named <code>_episodes</code>.
<ul>
<li>These episodes are numbered conventionally such that episode-01 corresponds to the first episode of that lesson, episode-02 to the second and so on.</li>
</ul></li>
</ul>
</section>
<section id="for-quarto-website-courses-metagenomics-automated-management-of-aws-instances" class="level3">
<h3 class="anchored" data-anchor-id="for-quarto-website-courses-metagenomics-automated-management-of-aws-instances">For Quarto website courses (<a href="https://cloud-span.github.io/nerc-metagenomics-v2q/">Metagenomics</a>, <a href="https://cloud-span.github.io/cloud-admin-guide-v2q/">Automated Management of AWS Instances</a>)</h3>
<ul>
<li>These courses are hosted such that all the lessons are together in a single repo which is built using the <a href="https://quarto.org/">Quarto</a> publishing system.</li>
<li>Each lesson exists as its own folder inside <code>docs</code>.
<ul>
<li>The homepage of the lesson is stored inside this folder as <code>index.qmd</code>.</li>
<li>Each episode has its own <code>.qmd</code> markdown file.</li>
</ul></li>
</ul>
</section>
</section>
<section id="contributing-via-github" class="level2">
<h2 class="anchored" data-anchor-id="contributing-via-github">Contributing via GitHub</h2>
<p><a href="https://git-scm.com">Git</a> is a really useful tool for version control. <a href="https://github.com">GitHub</a> sits on top of Git and supports collaborative and distributed working.</p>
<p>We know that it can be daunting to start using Git and GitHub if you haven’t worked with them in the past, but our maintainers are here to help you figure out any of the jargon or confusing instructions you encounter! :heart:</p>
<p>In order to contribute via GitHub, you’ll need to set up a free account and sign in. Here are some <a href="https://help.github.com/articles/signing-up-for-a-new-github-account/">instructions</a> to help you get going. Remember that you can ask us any questions you need to along the way.</p>
</section>
<section id="writing-in-markdown" class="level2">
<h2 class="anchored" data-anchor-id="writing-in-markdown">Writing in Markdown</h2>
<p>GitHub has a helpful page on <a href="https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github">getting started with writing and formatting on GitHub</a>.</p>
<p>Most of the writing that you’ll do will be in <a href="https://daringfireball.net/projects/markdown">Markdown</a>. You can think of Markdown as a few little symbols around your text that will allow GitHub to render the text with a little bit of formatting. For example, you could write words as <strong>bold</strong> (<code>**bold**</code>), or in <em>italics</em> (<code>_italics_</code>), or as a <a href="https://youtu.be/dQw4w9WgXcQ">link</a> (<code>[link](https://youtu.be/dQw4w9WgXcQ)</code>) to another webpage.</p>
<p>Also, when writing in Markdown please start each new sentence on a new line. Having each sentence on a new line will make no difference to how the text is displayed- there will still be paragraphs- but it makes the <a href="https://help.github.com/en/articles/about-comparing-branches-in-pull-requests">diffs produced during the pull request</a> review easier to read! :sparkles:</p>
</section>
<section id="share-your-thoughts" class="level2">
<h2 class="anchored" data-anchor-id="share-your-thoughts">Share your thoughts</h2>
<p>Whether you have something to contribute, a question to ask or a suggestion to make, the first thing you should do is open an issue. This keeps us up to date with any changes you’re thinking about and helps prevent unnecessary conflict between versions.</p>
<p>Please try and open your issue in the repository associated with the lesson or episode you want to contribute to. If your issue spans several lessons, or is more general, then just use your judgement. Our maintainers will sort you out if you get it wrong!</p>
<p>You should also check existing open issues to make sure you’re not duplicating someone else’s work.</p>
</section>
<section id="submitting-a-pull-request" class="level2">
<h2 class="anchored" data-anchor-id="submitting-a-pull-request">Submitting a pull request</h2>
<p>The following steps are a guide to help you contribute in a way that will be easy for everyone to review and accept with ease :sunglasses:.</p>
<section id="comment-on-an-existing-issue-or-open-a-new-issue-referencing-your-addition" class="level3">
<h3 class="anchored" data-anchor-id="comment-on-an-existing-issue-or-open-a-new-issue-referencing-your-addition">1. Comment on an existing issue or open a new issue referencing your addition</h3>
<p>This allows other members of the Cloud-SPAN team to confirm that you aren’t overlapping with work that’s currently underway and that everyone is on the same page with the goal of the work you’re going to carry out.</p>
<p><a href="https://www.igvita.com/2011/12/19/dont-push-your-pull-requests/">This blog</a> is a nice explanation of why putting this work in upfront is so useful to everyone involved.</p>
</section>
<section id="fork-the-relevant-repo" class="level3">
<h3 class="anchored" data-anchor-id="fork-the-relevant-repo">2. <a href="https://help.github.com/articles/fork-a-repo">Fork</a> the relevant repo</h3>
<p>This is now your own unique copy of that repo. Changes here won’t affect anyone else’s work, so it’s a safe space to explore edits to the code!</p>
<p>Make sure to <a href="https://help.github.com/articles/syncing-a-fork">keep your fork up to date</a> with the master repository, otherwise, you can end up with lots of dreaded <a href="https://help.github.com/articles/about-merge-conflicts">merge conflicts</a>. If you prefer working in the browser, <a href="https://github.com/KirstieJane/STEMMRoleModels/wiki/Syncing-your-fork-to-the-original-repository-via-the-browser">these instructions</a> describe how to sync your fork to the original repository via GitHub.</p>
</section>
<section id="make-the-changes-youve-discussed" class="level3">
<h3 class="anchored" data-anchor-id="make-the-changes-youve-discussed">3. Make the changes you’ve discussed</h3>
<p>Try to keep the changes focused. If you submit a large amount of work all in one go it will be much more work for whoever is reviewing your pull request. Help them help you. :wink:</p>
<p>While making your changes, commit often and write good, detailed commit messages. <a href="https://chris.beams.io/posts/git-commit/">This blog</a> explains how to write a good Git commit message and why it matters. It is also perfectly fine to have a lot of commits - including ones that break code.</p>
<p>If you feel tempted to “branch out” then please make a <a href="https://help.github.com/articles/creating-and-deleting-branches-within-your-repository">new branch</a> and a new issue to go with it. <a href="https://nvie.com/posts/a-successful-git-branching-model/">This blog</a> details the different Git branching models.</p>
<p>Please do not re-write history! That is, please do not use the <a href="https://help.github.com/en/articles/about-git-rebase">rebase</a> command to edit previous commit messages, combine multiple commits into one, or delete or revert commits that are no longer necessary.</p>
<p>Are you new to Git and GitHub or just want a detailed guide on getting started with version control? Check out the <a href="https://the-turing-way.netlify.com/version_control/version_control.html">Version Control chapter</a> in <em>The Turing Way</em> Book!</p>
</section>
<section id="submit-a-pull-request" class="level3">
<h3 class="anchored" data-anchor-id="submit-a-pull-request">4. Submit a <a href="https://help.github.com/articles/creating-a-pull-request">pull request</a></h3>
<p>We encourage you to open a pull request as early in your contributing process as possible. This allows everyone to see what is currently being worked on. It also provides you, the contributor, feedback in real-time from both the community and the continuous integration as you make commits (which will help prevent stuff from breaking).</p>
<p>When you are ready to submit a pull request, you will be asked to provide a title and description. The clearer your title and description are, the faster your request will be approved. - Describe the problem you’re trying to fix in the pull request, reference any related issue and use fixes/close to automatically close them, if pertinent. - Include a list of changes proposed in the pull request.</p>
<p>If you have opened the pull request early and know that its contents are not ready for review or to be merged, add “[WIP]” at the start of the pull request title, which stands for “Work in Progress”. When you are happy with it and are happy for it to be merged into the main repository, change the “[WIP]” in the title of the pull request to “[Ready for review]”.</p>
<p>A member of Cloud-SPAN team will then review your changes to confirm that they can be merged into the main repository. A <a href="https://help.github.com/articles/about-pull-request-reviews">review</a> will probably consist of a few questions to help clarify the work you’ve done. Keep an eye on your GitHub notifications and be prepared to join in that conversation.</p>
<p>You can update your <a href="https://help.github.com/articles/fork-a-repo">fork</a> of the repo and the pull request will automatically update with those changes. You don’t need to submit a new pull request when you make a change in response to a review.</p>
<p>GitHub has a <a href="https://guides.github.com/introduction/flow">nice introduction</a> to the pull request workflow, but please get in touch if you have any questions :balloon:.</p>
</section>
</section>
<section id="recognising-contributions" class="level2">
<h2 class="anchored" data-anchor-id="recognising-contributions">Recognising Contributions</h2>
<p>We welcome and recognise all kinds of contributions, from reporting/fixing bugs, to developing documentation, asking questions, answering questions, or suggesting new examples. Cloud-SPAN follows the <a href="https://github.com/kentcdodds/all-contributors#emoji-key">all-contributors</a> specifications. The all-contributors bot usage is described <a href="https://allcontributors.org/docs/en/bot/usage">here</a>.</p>
<p>The Cloud-SPAN project is split across multiple repos, so we use <strong>this repo</strong> (Cloud-SPAN-handbook) as our community hub. Regardless of which repo/lesson you have contributed to, we invite you to add yourself as a contributor here. To add yourself or someone else as a contributor, comment on the ‘add contributor’ issue in this repo with the following:</p>
<pre><code>@all-contributors please add <username> for <contributions></code></pre>
<p>You can see the <a href="https://allcontributors.org/docs/en/emoji-key">Emoji Key (Contribution Types Reference)</a> for a list of valid <code><contribution></code> types. The bot will then create a Pull Request to add the contributor and reply with the pull request details.</p>
<hr>
<p>These guidelines were adapted from the <a href="https://raw.githubusercontent.com/alan-turing-institute/the-turing-way/master/CONTRIBUTING.md">Contributing Guidelines</a> of the <a href="https://github.com/alan-turing-institute/the-turing-way">Turing Way</a> under a <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0 CA license</a>.</p>
</section>
</section>
</main>
<!-- /main column -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
const toggleBodyColorMode = (bsSheetEl) => {
const mode = bsSheetEl.getAttribute("data-mode");
const bodyEl = window.document.querySelector("body");
if (mode === "dark") {
bodyEl.classList.add("quarto-dark");
bodyEl.classList.remove("quarto-light");
} else {
bodyEl.classList.add("quarto-light");
bodyEl.classList.remove("quarto-dark");
}
}
const toggleBodyColorPrimary = () => {
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
if (bsSheetEl) {
toggleBodyColorMode(bsSheetEl);
}
}
toggleBodyColorPrimary();
const icon = "";
const anchorJS = new window.AnchorJS();
anchorJS.options = {
placement: 'right',
icon: icon
};
anchorJS.add('.anchored');
const isCodeAnnotation = (el) => {
for (const clz of el.classList) {
if (clz.startsWith('code-annotation-')) {
return true;
}
}
return false;
}
const clipboard = new window.ClipboardJS('.code-copy-button', {
text: function(trigger) {
const codeEl = trigger.previousElementSibling.cloneNode(true);
for (const childEl of codeEl.children) {
if (isCodeAnnotation(childEl)) {
childEl.remove();
}
}
return codeEl.innerText;
}
});
clipboard.on('success', function(e) {
// button target
const button = e.trigger;
// don't keep focus
button.blur();
// flash "checked"
button.classList.add('code-copy-button-checked');
var currentTitle = button.getAttribute("title");
button.setAttribute("title", "Copied!");
let tooltip;
if (window.bootstrap) {
button.setAttribute("data-bs-toggle", "tooltip");
button.setAttribute("data-bs-placement", "left");
button.setAttribute("data-bs-title", "Copied!");
tooltip = new bootstrap.Tooltip(button,
{ trigger: "manual",
customClass: "code-copy-button-tooltip",
offset: [0, -8]});
tooltip.show();
}
setTimeout(function() {
if (tooltip) {
tooltip.hide();
button.removeAttribute("data-bs-title");
button.removeAttribute("data-bs-toggle");
button.removeAttribute("data-bs-placement");
}
button.setAttribute("title", currentTitle);
button.classList.remove('code-copy-button-checked');
}, 1000);
// clear code selection
e.clearSelection();
});
var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
var mailtoRegex = new RegExp(/^mailto:/);
var filterRegex = new RegExp('/' + window.location.host + '/');
var isInternal = (href) => {
return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href);
}
// Inspect non-navigation links and adorn them if external
var links = window.document.querySelectorAll('a[href]:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external):not([aria-hidden]):not(.dropdown-item):not(.quarto-navigation-tool)');
for (var i=0; i<links.length; i++) {
const link = links[i];
if (!isInternal(link.href)) {
// undo the damage that might have been done by quarto-nav.js in the case of
// links that we want to consider external
if (link.dataset.originalHref !== undefined) {
link.href = link.dataset.originalHref;
}
}
}
function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
const config = {
allowHTML: true,
maxWidth: 500,
delay: 100,
arrow: false,
appendTo: function(el) {
return el.parentElement;
},
interactive: true,
interactiveBorder: 10,
theme: 'quarto',
placement: 'bottom-start',
};
if (contentFn) {
config.content = contentFn;
}
if (onTriggerFn) {
config.onTrigger = onTriggerFn;
}
if (onUntriggerFn) {
config.onUntrigger = onUntriggerFn;
}
window.tippy(el, config);
}
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
for (var i=0; i<noterefs.length; i++) {
const ref = noterefs[i];
tippyHover(ref, function() {
// use id or data attribute instead here
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
try { href = new URL(href).hash; } catch {}
const id = href.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
if (note) {
return note.innerHTML;
} else {
return "";
}
});
}
const xrefs = window.document.querySelectorAll('a.quarto-xref');
const processXRef = (id, note) => {
// Strip column container classes
const stripColumnClz = (el) => {
el.classList.remove("page-full", "page-columns");
if (el.children) {
for (const child of el.children) {
stripColumnClz(child);
}
}
}
stripColumnClz(note)
if (id === null || id.startsWith('sec-')) {
// Special case sections, only their first couple elements
const container = document.createElement("div");
if (note.children && note.children.length > 2) {
container.appendChild(note.children[0].cloneNode(true));
for (let i = 1; i < note.children.length; i++) {
const child = note.children[i];
if (child.tagName === "P" && child.innerText === "") {
continue;
} else {
container.appendChild(child.cloneNode(true));
break;
}
}
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(container);
}
return container.innerHTML
} else {
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(note);
}
return note.innerHTML;
}
} else {
// Remove any anchor links if they are present
const anchorLink = note.querySelector('a.anchorjs-link');
if (anchorLink) {
anchorLink.remove();
}
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(note);
}
// TODO in 1.5, we should make sure this works without a callout special case
if (note.classList.contains("callout")) {
return note.outerHTML;
} else {
return note.innerHTML;
}
}
}
for (var i=0; i<xrefs.length; i++) {
const xref = xrefs[i];
tippyHover(xref, undefined, function(instance) {
instance.disable();
let url = xref.getAttribute('href');
let hash = undefined;
if (url.startsWith('#')) {
hash = url;
} else {
try { hash = new URL(url).hash; } catch {}
}
if (hash) {
const id = hash.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
if (note !== null) {
try {
const html = processXRef(id, note.cloneNode(true));
instance.setContent(html);
} finally {
instance.enable();
instance.show();
}
} else {
// See if we can fetch this
fetch(url.split('#')[0])
.then(res => res.text())
.then(html => {
const parser = new DOMParser();
const htmlDoc = parser.parseFromString(html, "text/html");
const note = htmlDoc.getElementById(id);
if (note !== null) {
const html = processXRef(id, note);
instance.setContent(html);
}
}).finally(() => {
instance.enable();
instance.show();
});
}
} else {
// See if we can fetch a full url (with no hash to target)
// This is a special case and we should probably do some content thinning / targeting
fetch(url)
.then(res => res.text())
.then(html => {
const parser = new DOMParser();
const htmlDoc = parser.parseFromString(html, "text/html");
const note = htmlDoc.querySelector('main.content');
if (note !== null) {
// This should only happen for chapter cross references
// (since there is no id in the URL)
// remove the first header
if (note.children.length > 0 && note.children[0].tagName === "HEADER") {
note.children[0].remove();
}
const html = processXRef(null, note);
instance.setContent(html);
}
}).finally(() => {
instance.enable();
instance.show();
});
}
}, function(instance) {
});
}
let selectedAnnoteEl;
const selectorForAnnotation = ( cell, annotation) => {
let cellAttr = 'data-code-cell="' + cell + '"';
let lineAttr = 'data-code-annotation="' + annotation + '"';
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
return selector;
}
const selectCodeLines = (annoteEl) => {
const doc = window.document;
const targetCell = annoteEl.getAttribute("data-target-cell");
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
const lineIds = lines.map((line) => {
return targetCell + "-" + line;
})
let top = null;
let height = null;
let parent = null;
if (lineIds.length > 0) {
//compute the position of the single el (top and bottom and make a div)
const el = window.document.getElementById(lineIds[0]);
top = el.offsetTop;
height = el.offsetHeight;
parent = el.parentElement.parentElement;
if (lineIds.length > 1) {
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
height = bottom - top;
}
if (top !== null && height !== null && parent !== null) {
// cook up a div (if necessary) and position it
let div = window.document.getElementById("code-annotation-line-highlight");
if (div === null) {
div = window.document.createElement("div");
div.setAttribute("id", "code-annotation-line-highlight");
div.style.position = 'absolute';
parent.appendChild(div);
}
div.style.top = top - 2 + "px";
div.style.height = height + 4 + "px";
div.style.left = 0;
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
if (gutterDiv === null) {
gutterDiv = window.document.createElement("div");
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
gutterDiv.style.position = 'absolute';
const codeCell = window.document.getElementById(targetCell);
const gutter = codeCell.querySelector('.code-annotation-gutter');
gutter.appendChild(gutterDiv);
}
gutterDiv.style.top = top - 2 + "px";
gutterDiv.style.height = height + 4 + "px";
}
selectedAnnoteEl = annoteEl;
}
};
const unselectCodeLines = () => {
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
elementsIds.forEach((elId) => {
const div = window.document.getElementById(elId);
if (div) {
div.remove();
}
});
selectedAnnoteEl = undefined;
};
// Handle positioning of the toggle
window.addEventListener(
"resize",
throttle(() => {
elRect = undefined;
if (selectedAnnoteEl) {
selectCodeLines(selectedAnnoteEl);
}
}, 10)
);
function throttle(fn, ms) {
let throttle = false;
let timer;
return (...args) => {
if(!throttle) { // first call gets through
fn.apply(this, args);
throttle = true;
} else { // all the others get throttled
if(timer) clearTimeout(timer); // cancel #2
timer = setTimeout(() => {
fn.apply(this, args);
timer = throttle = false;
}, ms);
}
};
}
// Attach click handler to the DT
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
for (const annoteDlNode of annoteDls) {
annoteDlNode.addEventListener('click', (event) => {
const clickedEl = event.target;
if (clickedEl !== selectedAnnoteEl) {
unselectCodeLines();
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
if (activeEl) {
activeEl.classList.remove('code-annotation-active');
}
selectCodeLines(clickedEl);
clickedEl.classList.add('code-annotation-active');
} else {
// Unselect the line
unselectCodeLines();
clickedEl.classList.remove('code-annotation-active');
}
});
}
const findCites = (el) => {
const parentEl = el.parentElement;
if (parentEl) {
const cites = parentEl.dataset.cites;
if (cites) {
return {
el,
cites: cites.split(' ')
};
} else {
return findCites(el.parentElement)
}
} else {
return undefined;
}
};
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
for (var i=0; i<bibliorefs.length; i++) {
const ref = bibliorefs[i];
const citeInfo = findCites(ref);
if (citeInfo) {
tippyHover(citeInfo.el, function() {
var popup = window.document.createElement('div');
citeInfo.cites.forEach(function(cite) {
var citeDiv = window.document.createElement('div');
citeDiv.classList.add('hanging-indent');
citeDiv.classList.add('csl-entry');
var biblioDiv = window.document.getElementById('ref-' + cite);
if (biblioDiv) {
citeDiv.innerHTML = biblioDiv.innerHTML;
}
popup.appendChild(citeDiv);
});
return popup.innerHTML;
});
}
}
});
</script>
</div> <!-- /content -->
</body></html>