You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/examples/custom-formats.Rmd
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ nb_custom_formats = {
33
33
34
34
:::{important}
35
35
36
-
By default, Markdown cells in the Notebook will be parsed using the same MyST parser configuration as for other Markdown files ([see available configuration options](start/config-options)).
36
+
By default, Markdown cells in the Notebook will be parsed using the same MyST parser configuration as for other Markdown files ([see available configuration options](config/reference)).
37
37
38
38
But, if this is incompatible with your file format, then you can specify for the Markdown to be parsed as **strictly CommonMark**, using a third argument:
39
39
@@ -56,7 +56,7 @@ This key should be a list mapping each cell to the starting line number in the o
56
56
}
57
57
```
58
58
59
-
This mapping allows for "true" error reporting, as described in [](start/error-reporting).
59
+
This mapping allows for "true" error reporting, as described in [](myst/error-reporting).
This page lists the configuration options that are available to control MyST-NB.
6
+
For more detailed explanation of when to use each option, see the other sections in the documentation.
7
+
8
+
## MyST Parser configuration
9
+
10
+
The MyST-NB parser derives from {ref}`the base MyST-Parser <myst:intro/get-started>`, and so all the same configuration options are available.
11
+
See the {ref}`MyST configuration options <myst:sphinx/config-options>` for the full set of options.
12
+
13
+
## Notebook execution configuration
14
+
15
+
This configuration is used to control how Jupyter Notebooks are executed at build-time.
16
+
17
+
`````{list-table}
18
+
:header-rows: 1
19
+
20
+
* - Option
21
+
- Default
22
+
- Description
23
+
* - `jupyter_cache`
24
+
- ""
25
+
- Path to jupyter_cache, [see here](execute/cache) for details.
26
+
* - `execution_excludepatterns`
27
+
- ()
28
+
- Exclude certain file patterns from execution, [see here](execute/config) for details.
29
+
* - `jupyter_execute_notebooks`
30
+
- "auto"
31
+
- The logic for executing notebooks, [see here](execute/config) for details.
32
+
* - `execution_in_temp`
33
+
- `False`
34
+
- If `True`, then a temporary directory will be created and used as the command working directory (cwd), if `False` then the notebook's parent directory will be the cwd.
35
+
* - `execution_allow_errors`
36
+
- `False`
37
+
- If `False`, when a code cell raises an error the execution is stopped, if `True` then all cells are always run.
38
+
This can also be overridden by metadata in a notebook, [see here](execute/allow_errors) for details.
39
+
* - `execution_timeout`
40
+
- 30
41
+
- The maximum time (in seconds) each notebook cell is allowed to run.
42
+
This can also be overridden by metadata in a notebook, [see here](execute/timeout) for details.
43
+
* - `execution_show_tb`
44
+
- `False`
45
+
- Show failed notebook tracebacks in stdout (in addition to writing to file).
46
+
`````
47
+
48
+
## Notebook parsing and output rendering
49
+
50
+
These configuration options affect the look and feel of notebook parsing and output rendering.
51
+
52
+
`````{list-table}
53
+
:header-rows: 1
54
+
55
+
* - Option
56
+
- Default
57
+
- Description
58
+
* - `nb_custom_formats`
59
+
- `{}`
60
+
- Define custom functions for conversion of files to notebooks, [see here](examples/custom_formats) for details.
61
+
* - `nb_render_priority`
62
+
- `{}`
63
+
- Dict override for MIME type render priority, [see here](use/format/priority) for details.
64
+
* - `nb_render_plugin`
65
+
- `default`
66
+
- Entry point pointing toward a code cell output renderer, [see here](use/format/cutomise) for details.
67
+
* - `nb_render_text_lexer`
68
+
- `myst-ansi`
69
+
- pygments lexer for rendering text outputs, [see here](use/format/ansi) for details.
70
+
* - `nb_render_key`
71
+
- `render`
72
+
- The top-level cell metadata key, to store render control data, [see here](use/format/images) for examples.
73
+
* - `nb_output_stderr`
74
+
- `show`
75
+
- One of 'show', 'remove', 'warn', 'error' or 'severe', [see here](use/format/stderr) for details.
76
+
* - `nb_merge_streams`
77
+
- `False`
78
+
- If `True`, ensure all stdout / stderr output streams are merged into single outputs. This ensures deterministic outputs.
Copy file name to clipboardExpand all lines: docs/use/formatting_outputs.md
+22-2Lines changed: 22 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ kernelspec:
12
12
---
13
13
14
14
(use/format)=
15
-
# Formatting code outputs
15
+
# Format code outputs
16
16
17
17
(use/format/priority)=
18
18
## Render priority
@@ -42,8 +42,11 @@ nb_render_priority = {
42
42
[](use/format/cutomise), for a more advanced means of customisation.
43
43
:::
44
44
45
+
(use/format/stdout-stderr)=
46
+
## stdout and stderr
47
+
45
48
(use/format/stderr)=
46
-
##Removing stdout and stderr
49
+
### Remove stdout or stderr
47
50
48
51
In some cases you may not wish to display stdout/stderr outputs in your final documentation,
49
52
for example, if they are only for debugging purposes.
@@ -80,6 +83,23 @@ This can be set to:
80
83
-`"remove-warn"`: remove all stderr, but log a warning to sphinx if any found
81
84
-`"warn"`, `"error"` or `"severe"`: log to sphinx, at a certain level, if any found.
82
85
86
+
(use/format/group-stderr-stdout)=
87
+
### Group stdout and stderr into single streams
88
+
89
+
Cells may print multiple things to `stdout` and `stderr`.
90
+
For example, if a cell prints status updates throughout its execution, each of these is often printed to `stdout`.
91
+
By default, these outputs may be split across multiple items, and will be rendered as separate "chunks" in your built documentation.
92
+
93
+
If you'd like each of the outputs in `stderr` and `stdout` to be merged into a single stream for each, use the following configuration:
94
+
95
+
```python
96
+
nb_merge_streams =True
97
+
```
98
+
99
+
This will ensure that all `stderr` and `stdout` outputs are merged into a single group.
100
+
This also makes cell outputs more deterministic.
101
+
Normally, slight differences in timing may result in different orders of `stderr` and `stdout` in the cell output, while this setting will sort them properly.
This section covers how to get started with the `MyST-NB` Sphinx extension.
4
-
The Sphinx extension allows you to read markdown (`.md`) and Jupyter Notebook (`.ipynb`)
5
-
files into your Sphinx site. It also enables you to write [MyST Markdown](myst.md)
6
-
in your pages.
4
+
The Sphinx extension allows you to read markdown (`.md`) and Jupyter Notebook (`.ipynb`) files into your Sphinx site.
5
+
It also enables you to write [MyST Markdown](myst.md) in your pages.
7
6
8
-
## Install and activate
9
-
10
-
To install `myst-nb`, do the following:
7
+
To get started with the extension, follow these steps.
11
8
12
9
***Install**`myst-nb` with the following command:
13
10
14
-
```bash
15
-
pip install myst-nb
11
+
```console
12
+
$ pip install myst-nb
16
13
```
17
14
18
15
***Activate** the `myst_nb` extension in your Sphinx site by adding it to your list of
@@ -25,94 +22,15 @@ To install `myst-nb`, do the following:
25
22
]
26
23
```
27
24
28
-
Once you do this, MyST-NB will now parse both markdown (`.md`), Jupyter notebooks (`.ipynb`), and even [text-based Notebooks](markdown.md) (`.md`) into your Sphinx site
29
-
(see also [custom notebook formats](examples/custom_formats)).
30
-
31
-
(start/error-reporting)=
32
-
33
-
## Sphinx Error Reporting
34
-
35
-
For `.md` files, sphinx will correctly report the line number that the error or warning is associated with:
The MyST-NB parser derives from {ref}`the base MyST-Parser <myst:intro/get-started>`, and so all the same configuration options are available.
53
-
See the {ref}`MyST configuration options <myst:sphinx/config-options>` for the full set of options.
54
-
55
-
MyST-NB then adds some additional configuration, specific to notebooks.
56
-
Firstly for execution:
57
-
58
-
`````{list-table}
59
-
:header-rows: 1
25
+
***Add MyST and notebook content** to your documentation's source files.
26
+
Sphinx will now be able to parse **markdown files** written in [MyST Markdown](https://myst-parser.readthedocs.io), Jupyter Notebooks (ending in `.ipynb`), and [Jupyter Notebooks written in plain-text with MyST markdown](markdown.md).
27
+
Make sure to include paths to your content in a Sphinx `toctree` directive!
60
28
61
-
* - Option
62
-
- Default
63
-
- Description
64
-
* - `jupyter_cache`
65
-
- ""
66
-
- Path to jupyter_cache, [see here](execute/cache) for details.
67
-
* - `execution_excludepatterns`
68
-
- ()
69
-
- Exclude certain file patterns from execution, [see here](execute/config) for details.
70
-
* - `jupyter_execute_notebooks`
71
-
- "auto"
72
-
- The logic for executing notebooks, [see here](execute/config) for details.
73
-
* - `execution_in_temp`
74
-
- `False`
75
-
- If `True`, then a temporary directory will be created and used as the command working directory (cwd), if `False` then the notebook's parent directory will be the cwd.
76
-
* - `execution_allow_errors`
77
-
- `False`
78
-
- If `False`, when a code cell raises an error the execution is stopped, if `True` then all cells are always run.
79
-
This can also be overridden by metadata in a notebook, [see here](execute/allow_errors) for details.
80
-
* - `execution_timeout`
81
-
- 30
82
-
- The maximum time (in seconds) each notebook cell is allowed to run.
83
-
This can also be overridden by metadata in a notebook, [see here](execute/timeout) for details.
84
-
* - `execution_show_tb`
85
-
- `False`
86
-
- Show failed notebook tracebacks in stdout (in addition to writing to file).
87
-
`````
29
+
***Build your documentation**. MyST-NB will now parse any markdown (`.md`), Jupyter notebooks (`.ipynb`), and [text-based Notebooks](markdown.md) (`.md`) into your Sphinx site, and include them in the outputs.
88
30
89
-
Then for parsing and output rendering:
31
+
## Next steps
90
32
91
-
`````{list-table}
92
-
:header-rows: 1
33
+
There is a lot more that you can do with MyST-NB.
34
+
For example, you can define [custom text-based notebook formats](examples/custom_formats), [execute and cache notebook content](execute.md), and [format cell outputs](formatting_outputs.md).
93
35
94
-
* - Option
95
-
- Default
96
-
- Description
97
-
* - `nb_custom_formats`
98
-
- `{}`
99
-
- Define custom functions for conversion of files to notebooks, [see here](examples/custom_formats) for details.
100
-
* - `nb_render_priority`
101
-
- `{}`
102
-
- Dict override for MIME type render priority, [see here](use/format/priority) for details.
103
-
* - `nb_render_plugin`
104
-
- `default`
105
-
- Entry point pointing toward a code cell output renderer, [see here](use/format/cutomise) for details.
106
-
* - `nb_render_text_lexer`
107
-
- `myst-ansi`
108
-
- pygments lexer for rendering text outputs, [see here](use/format/ansi) for details.
109
-
* - `nb_render_key`
110
-
- `render`
111
-
- The top-level cell metadata key, to store render control data, [see here](use/format/images) for examples.
112
-
* - `nb_output_stderr`
113
-
- `show`
114
-
- One of 'show', 'remove', 'warn', 'error' or 'severe', [see here](use/format/stderr) for details.
115
-
* - `nb_merge_streams`
116
-
- `False`
117
-
- If `True`, ensure all stdout / stderr output streams are merged into single outputs. This ensures deterministic outputs.
118
-
`````
36
+
Check out the sections to the left under [Using with Sphinx](index.md) for more information.
0 commit comments