Skip to content

Commit a4119a6

Browse files
committed
Update documentation
0 parents  commit a4119a6

File tree

165 files changed

+12813
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+12813
-0
lines changed

.buildinfo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Sphinx build info version 1
2+
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: 1ece39bac2918189bb2d71a3e085330e
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7

.nojekyll

Whitespace-only changes.
161 KB
Loading

_sources/intro.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Welcome to your Jupyter Book
2+
3+
This is a small sample book to give you a feel for how book content is
4+
structured.
5+
It shows off a few of the major file types, as well as some sample content.
6+
It does not go in-depth into any particular topic - check out [the Jupyter Book documentation](https://jupyterbook.org) for more information.
7+
8+
Check out the content pages bundled with this sample book to see more.
9+
10+
```{tableofcontents}
11+
```

_sources/markdown-notebooks.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
jupytext:
3+
formats: md:myst
4+
text_representation:
5+
extension: .md
6+
format_name: myst
7+
format_version: 0.13
8+
jupytext_version: 1.11.5
9+
kernelspec:
10+
display_name: Python 3
11+
language: python
12+
name: python3
13+
---
14+
15+
# Notebooks with MyST Markdown
16+
17+
Jupyter Book also lets you write text-based notebooks using MyST Markdown.
18+
See [the Notebooks with MyST Markdown documentation](https://jupyterbook.org/file-types/myst-notebooks.html) for more detailed instructions.
19+
This page shows off a notebook written in MyST Markdown.
20+
21+
## An example cell
22+
23+
With MyST Markdown, you can define code cells with a directive like so:
24+
25+
```{code-cell}
26+
print(2 + 2)
27+
```
28+
29+
When your book is built, the contents of any `{code-cell}` blocks will be
30+
executed with your default Jupyter kernel, and their outputs will be displayed
31+
in-line with the rest of your content.
32+
33+
```{seealso}
34+
Jupyter Book uses [Jupytext](https://jupytext.readthedocs.io/en/latest/) to convert text-based files to notebooks, and can support [many other text-based notebook files](https://jupyterbook.org/file-types/jupytext.html).
35+
```
36+
37+
## Create a notebook with MyST Markdown
38+
39+
MyST Markdown notebooks are defined by two things:
40+
41+
1. YAML metadata that is needed to understand if / how it should convert text files to notebooks (including information about the kernel needed).
42+
See the YAML at the top of this page for example.
43+
2. The presence of `{code-cell}` directives, which will be executed with your book.
44+
45+
That's all that is needed to get started!
46+
47+
## Quickly add YAML metadata for MyST Notebooks
48+
49+
If you have a markdown file and you'd like to quickly add YAML metadata to it, so that Jupyter Book will treat it as a MyST Markdown Notebook, run the following command:
50+
51+
```
52+
jupyter-book myst init path/to/markdownfile.md
53+
```

_sources/markdown.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Markdown Files
2+
3+
Whether you write your book's content in Jupyter Notebooks (`.ipynb`) or
4+
in regular markdown files (`.md`), you'll write in the same flavor of markdown
5+
called **MyST Markdown**.
6+
This is a simple file to help you get started and show off some syntax.
7+
8+
## What is MyST?
9+
10+
MyST stands for "Markedly Structured Text". It
11+
is a slight variation on a flavor of markdown called "CommonMark" markdown,
12+
with small syntax extensions to allow you to write **roles** and **directives**
13+
in the Sphinx ecosystem.
14+
15+
For more about MyST, see [the MyST Markdown Overview](https://jupyterbook.org/content/myst.html).
16+
17+
## Sample Roles and Directives
18+
19+
Roles and directives are two of the most powerful tools in Jupyter Book. They
20+
are like functions, but written in a markup language. They both
21+
serve a similar purpose, but **roles are written in one line**, whereas
22+
**directives span many lines**. They both accept different kinds of inputs,
23+
and what they do with those inputs depends on the specific role or directive
24+
that is being called.
25+
26+
Here is a "note" directive:
27+
28+
```{note}
29+
Here is a note
30+
```
31+
32+
It will be rendered in a special box when you build your book.
33+
34+
Here is an inline directive to refer to a document: {doc}`markdown-notebooks`.
35+
36+
37+
## Citations
38+
39+
You can also cite references that are stored in a `bibtex` file. For example,
40+
the following syntax: `` {cite}`holdgraf_evidence_2014` `` will render like
41+
this: {cite}`holdgraf_evidence_2014`.
42+
43+
Moreover, you can insert a bibliography into your page with this syntax:
44+
The `{bibliography}` directive must be used for all the `{cite}` roles to
45+
render properly.
46+
For example, if the references for your book are stored in `references.bib`,
47+
then the bibliography is inserted with:
48+
49+
```{bibliography}
50+
```
51+
52+
## Learn more
53+
54+
This is just a simple starter to get you started.
55+
You can learn a lot more at [jupyterbook.org](https://jupyterbook.org).

_sources/notebooks.ipynb

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Content with notebooks\n",
8+
"\n",
9+
"You can also create content with Jupyter Notebooks. This means that you can include\n",
10+
"code blocks and their outputs in your book.\n",
11+
"\n",
12+
"## Markdown + notebooks\n",
13+
"\n",
14+
"As it is markdown, you can embed images, HTML, etc into your posts!\n",
15+
"\n",
16+
"![](https://myst-parser.readthedocs.io/en/latest/_static/logo-wide.svg)\n",
17+
"\n",
18+
"You can also $add_{math}$ and\n",
19+
"\n",
20+
"$$\n",
21+
"math^{blocks}\n",
22+
"$$\n",
23+
"\n",
24+
"or\n",
25+
"\n",
26+
"$$\n",
27+
"\\begin{aligned}\n",
28+
"\\mbox{mean} la_{tex} \\\\ \\\\\n",
29+
"math blocks\n",
30+
"\\end{aligned}\n",
31+
"$$\n",
32+
"\n",
33+
"But make sure you \\$Escape \\$your \\$dollar signs \\$you want to keep!\n",
34+
"\n",
35+
"## MyST markdown\n",
36+
"\n",
37+
"MyST markdown works in Jupyter Notebooks as well. For more information about MyST markdown, check\n",
38+
"out [the MyST guide in Jupyter Book](https://jupyterbook.org/content/myst.html),\n",
39+
"or see [the MyST markdown documentation](https://myst-parser.readthedocs.io/en/latest/).\n",
40+
"\n",
41+
"## Code blocks and outputs\n",
42+
"\n",
43+
"Jupyter Book will also embed your code blocks and output in your book.\n",
44+
"For example, here's some sample Matplotlib code:"
45+
]
46+
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": null,
50+
"metadata": {},
51+
"outputs": [],
52+
"source": [
53+
"from matplotlib import rcParams, cycler\n",
54+
"import matplotlib.pyplot as plt\n",
55+
"import numpy as np\n",
56+
"plt.ion()"
57+
]
58+
},
59+
{
60+
"cell_type": "code",
61+
"execution_count": null,
62+
"metadata": {},
63+
"outputs": [],
64+
"source": [
65+
"# Fixing random state for reproducibility\n",
66+
"np.random.seed(19680801)\n",
67+
"\n",
68+
"N = 10\n",
69+
"data = [np.logspace(0, 1, 100) + np.random.randn(100) + ii for ii in range(N)]\n",
70+
"data = np.array(data).T\n",
71+
"cmap = plt.cm.coolwarm\n",
72+
"rcParams['axes.prop_cycle'] = cycler(color=cmap(np.linspace(0, 1, N)))\n",
73+
"\n",
74+
"\n",
75+
"from matplotlib.lines import Line2D\n",
76+
"custom_lines = [Line2D([0], [0], color=cmap(0.), lw=4),\n",
77+
" Line2D([0], [0], color=cmap(.5), lw=4),\n",
78+
" Line2D([0], [0], color=cmap(1.), lw=4)]\n",
79+
"\n",
80+
"fig, ax = plt.subplots(figsize=(10, 5))\n",
81+
"lines = ax.plot(data)\n",
82+
"ax.legend(custom_lines, ['Cold', 'Medium', 'Hot']);"
83+
]
84+
},
85+
{
86+
"cell_type": "markdown",
87+
"metadata": {},
88+
"source": [
89+
"There is a lot more that you can do with outputs (such as including interactive outputs)\n",
90+
"with your book. For more information about this, see [the Jupyter Book documentation](https://jupyterbook.org)"
91+
]
92+
}
93+
],
94+
"metadata": {
95+
"kernelspec": {
96+
"display_name": "Python 3",
97+
"language": "python",
98+
"name": "python3"
99+
},
100+
"language_info": {
101+
"codemirror_mode": {
102+
"name": "ipython",
103+
"version": 3
104+
},
105+
"file_extension": ".py",
106+
"mimetype": "text/x-python",
107+
"name": "python",
108+
"nbconvert_exporter": "python",
109+
"pygments_lexer": "ipython3",
110+
"version": "3.8.0"
111+
},
112+
"widgets": {
113+
"application/vnd.jupyter.widget-state+json": {
114+
"state": {},
115+
"version_major": 2,
116+
"version_minor": 0
117+
}
118+
}
119+
},
120+
"nbformat": 4,
121+
"nbformat_minor": 4
122+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// @ts-check
2+
3+
// Extra JS capability for selected tabs to be synced
4+
// The selection is stored in local storage so that it persists across page loads.
5+
6+
/**
7+
* @type {Record<string, HTMLElement[]>}
8+
*/
9+
let sd_id_to_elements = {};
10+
const storageKeyPrefix = "sphinx-design-tab-id-";
11+
12+
/**
13+
* Create a key for a tab element.
14+
* @param {HTMLElement} el - The tab element.
15+
* @returns {[string, string, string] | null} - The key.
16+
*
17+
*/
18+
function create_key(el) {
19+
let syncId = el.getAttribute("data-sync-id");
20+
let syncGroup = el.getAttribute("data-sync-group");
21+
if (!syncId || !syncGroup) return null;
22+
return [syncGroup, syncId, syncGroup + "--" + syncId];
23+
}
24+
25+
/**
26+
* Initialize the tab selection.
27+
*
28+
*/
29+
function ready() {
30+
// Find all tabs with sync data
31+
32+
/** @type {string[]} */
33+
let groups = [];
34+
35+
document.querySelectorAll(".sd-tab-label").forEach((label) => {
36+
if (label instanceof HTMLElement) {
37+
let data = create_key(label);
38+
if (data) {
39+
let [group, id, key] = data;
40+
41+
// add click event listener
42+
// @ts-ignore
43+
label.onclick = onSDLabelClick;
44+
45+
// store map of key to elements
46+
if (!sd_id_to_elements[key]) {
47+
sd_id_to_elements[key] = [];
48+
}
49+
sd_id_to_elements[key].push(label);
50+
51+
if (groups.indexOf(group) === -1) {
52+
groups.push(group);
53+
// Check if a specific tab has been selected via URL parameter
54+
const tabParam = new URLSearchParams(window.location.search).get(
55+
group
56+
);
57+
if (tabParam) {
58+
console.log(
59+
"sphinx-design: Selecting tab id for group '" +
60+
group +
61+
"' from URL parameter: " +
62+
tabParam
63+
);
64+
window.sessionStorage.setItem(storageKeyPrefix + group, tabParam);
65+
}
66+
}
67+
68+
// Check is a specific tab has been selected previously
69+
let previousId = window.sessionStorage.getItem(
70+
storageKeyPrefix + group
71+
);
72+
if (previousId === id) {
73+
// console.log(
74+
// "sphinx-design: Selecting tab from session storage: " + id
75+
// );
76+
// @ts-ignore
77+
label.previousElementSibling.checked = true;
78+
}
79+
}
80+
}
81+
});
82+
}
83+
84+
/**
85+
* Activate other tabs with the same sync id.
86+
*
87+
* @this {HTMLElement} - The element that was clicked.
88+
*/
89+
function onSDLabelClick() {
90+
let data = create_key(this);
91+
if (!data) return;
92+
let [group, id, key] = data;
93+
for (const label of sd_id_to_elements[key]) {
94+
if (label === this) continue;
95+
// @ts-ignore
96+
label.previousElementSibling.checked = true;
97+
}
98+
window.sessionStorage.setItem(storageKeyPrefix + group, id);
99+
}
100+
101+
document.addEventListener("DOMContentLoaded", ready, false);

_sphinx_design_static/sphinx-design.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)