Skip to content

Commit 8777a4c

Browse files
authored
Merge branch 'master' into sphinx-7
2 parents e4cf22c + 48c45c6 commit 8777a4c

9 files changed

Lines changed: 29 additions & 22 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ WARNING: 'jupyter_execute_notebooks' is deprecated for 'nb_execution_mode' [myst
9292

9393
`nb_render_priority` has been removed and replaced by `nb_mime_priority_overrides`, which has a different format and is more flexible. See [Outputs MIME priority](docs/render/format_code_cells.md) for more information.
9494

95-
As per the changes in [`myst_parser`](myst:develop/_changelog), the `dollarmath` syntax extension is no longer included by default.
95+
As per the changes in [`myst_parser`](inv:myst#develop/_changelog), the `dollarmath` syntax extension is no longer included by default.
9696
To re-add this extension, ensure that it is specified in your `conf.py`: `myst_enable_extensions = ["dollarmath"]`.
9797

9898
For cell-level configuration the top-level key `render` has now been deprecated for `mystnb`.
@@ -168,7 +168,7 @@ See [Embedding outputs as variables](docs/render/glue.md) for more details.
168168
- `nbconvert`
169169
- Updated:
170170
- `Python`: `3.6+ -> 3.7+`
171-
- `myst_parser`: [`0.15 -> 0.17`](myst:develop/_changelog)
171+
- `myst_parser`: [`0.15 -> 0.17`](inv:myst#develop/_changelog)
172172
- `jupyter-cache`: [`0.4 -> 0.5`](https://github.com/executablebooks/jupyter-cache/blob/master/CHANGELOG.md)
173173
- `sphinx-togglebutton`: [`0.1 -> 0.3`](https://sphinx-togglebutton.readthedocs.io/en/latest/changelog.html)
174174

docs/authoring/custom-formats.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ nb_custom_formats = {
2121
```
2222

2323
- The string should be a Python function that will be loaded by `import mylibrary.converter_function`
24-
- The function should take a file's contents (as a `str`) and return an [nbformat.NotebookNode](nbformat:api)
24+
- The function should take a file's contents (as a `str`) and return an [nbformat.NotebookNode](inv:nbformat#api)
2525

2626
If the function takes additional keyword arguments, then you can specify these as dictionary in a second argument.
2727
For example this is what the default conversion would look like:

docs/authoring/jupyter-notebooks.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ Sphinx using the MyST parser.[^download]
1616

1717
:::{seealso}
1818
For more information about what you can write with MyST Markdown, see the
19-
[MyST Parser documentation](myst:intro/get-started).
19+
[MyST Parser documentation](inv:myst#intro/get-started).
2020
:::
2121

2222
### Configuration
2323

24-
The MyST-NB parser derives from [the base MyST-Parser](myst:intro/get-started), and so all the same configuration options are available.
25-
See the [MyST configuration options](myst:sphinx/config-options) for the full set of options, and [MyST syntax guide](myst:syntax/core) for all the syntax options.
24+
The MyST-NB parser derives from [the base MyST-Parser](inv:myst#intro/get-started), and so all the same configuration options are available.
25+
See the [MyST configuration options](inv:myst#sphinx/config-options) for the full set of options, and [MyST syntax guide](inv:myst#syntax/core) for all the syntax options.
2626

2727
To build documentation from this notebook, the following options are set:
2828

@@ -38,7 +38,7 @@ myst_url_schemes = ("http", "https", "mailto")
3838
```
3939

4040
:::{note}
41-
Loading the `myst_nb` extension also activates the [`myst_parser`](myst:index) extension, for enabling the MyST flavour of Markdown.
41+
Loading the `myst_nb` extension also activates the [`myst_parser`](inv:myst#index) extension, for enabling the MyST flavour of Markdown.
4242
It is not required to add this explicitly in the list of `extensions`.
4343
:::
4444

@@ -53,7 +53,7 @@ For example, here's the MyST-NB logo:
5353

5454
![myst-nb logo](../_static/logo-wide.svg)
5555

56-
By adding `"html_image"` to the `myst_enable_extensions` list in the sphinx configuration ([see here](myst:syntax/images)), you can even add HTML `img` tags with attributes:
56+
By adding `"html_image"` to the `myst_enable_extensions` list in the sphinx configuration ([see here](inv:myst#syntax/images)), you can even add HTML `img` tags with attributes:
5757

5858
```html
5959
<img src="../_static/logo-wide.svg" alt="logo" width="200px" class="shadow mb-2">
@@ -66,7 +66,7 @@ For example, here's a note admonition block:
6666

6767
:::::{note}
6868
**Wow**, a note!
69-
It was generated with this code ([as explained here](myst:syntax/admonitions)):
69+
It was generated with this code ([as explained here](inv:myst:std:label#syntax/admonitions)):
7070

7171
````md
7272
:::{note}
@@ -77,7 +77,7 @@ It was generated with this code ([as explained here](myst:syntax/admonitions)):
7777
:::::
7878

7979
If you wish to use "bare" LaTeX equations, then you should add `"amsmath"` to the `myst_enable_extensions` list in the sphinx configuration.
80-
This is [explained here](myst:syntax/amsmath), and works as such:
80+
This is [explained here](inv:myst:std:label#syntax/amsmath), and works as such:
8181

8282
```latex
8383
\begin{equation}
@@ -110,7 +110,7 @@ $$e^{i\pi} + 1 = 0$$ (euler)
110110
Euler's identity, equation {math:numref}`euler`, was elected one of the
111111
most beautiful mathematical formulas.
112112

113-
You can see the syntax used for this example [here in the MyST documentation](myst:syntax/math).
113+
You can see the syntax used for this example [here in the MyST documentation](inv:myst:std:label#syntax/math).
114114

115115
## Code cells and outputs
116116

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Build single or collections of documents into multiple formats (HTML, PDF, ...).
8686

8787
MyST-NB is a module within the [Executable Books Project](https://executablebooks.org),
8888
an international collaboration to build open source tools that facilitate publishing computational narratives using the Jupyter ecosystem.
89-
It is also a core component of [Jupyter Book](jb:intro).
89+
It is also a core component of [Jupyter Book](inv:jb#intro).
9090

9191
Check out the [Gallery of Jupyter Books](https://executablebooks.org/en/latest/gallery),
9292
for inspiration from across the community.

myst_nb/core/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ def __post_init__(self):
195195
"sections": (Section.global_lvl, Section.execute),
196196
},
197197
)
198+
eval_name_regex: str = dc.field(
199+
default=r"^[a-zA-Z_][a-zA-Z0-9_]*$",
200+
metadata={
201+
"validator": instance_of(str),
202+
"help": "Regex that matches permitted values of eval expressions",
203+
"sections": (Section.global_lvl, Section.file_lvl, Section.execute),
204+
},
205+
)
198206
execution_mode: Literal["off", "force", "auto", "cache", "inline"] = dc.field(
199207
default="auto",
200208
metadata={

myst_nb/core/execute/base.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from __future__ import annotations
33

44
from pathlib import Path
5-
import re
65
from typing import Any
76

87
from nbformat import NotebookNode
@@ -39,9 +38,6 @@ class EvalNameError(Exception):
3938
"""An exception for if an evaluation variable name is invalid."""
4039

4140

42-
EVAL_NAME_REGEX = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_]*$")
43-
44-
4541
class NotebookClientBase:
4642
"""A base client for interacting with Jupyter notebooks.
4743

myst_nb/core/execute/inline.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import asyncio
55
from datetime import datetime
6+
import re
67
import shutil
78
from tempfile import mkdtemp
89
import time
@@ -22,7 +23,7 @@
2223

2324
from myst_nb.ext.glue import extract_glue_data_cell
2425

25-
from .base import EVAL_NAME_REGEX, EvalNameError, ExecutionError, NotebookClientBase
26+
from .base import EvalNameError, ExecutionError, NotebookClientBase
2627

2728

2829
class NotebookClientInline(NotebookClientBase):
@@ -148,7 +149,7 @@ def code_cell_outputs(
148149
return cell.get("execution_count", None), cell.get("outputs", [])
149150

150151
def eval_variable(self, name: str) -> list[NotebookNode]:
151-
if not EVAL_NAME_REGEX.match(name):
152+
if not re.match(self.nb_config.eval_name_regex, name):
152153
raise EvalNameError(name)
153154
return self._client.eval_expression(name)
154155

myst_nb/ext/eval/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ def retrieve_eval_data(document: nodes.document, key: str) -> list[VariableOutpu
4343
except NotImplementedError:
4444
raise RetrievalError("This document does not have a running kernel")
4545
except EvalNameError:
46-
raise RetrievalError(f"The variable {key!r} is not a valid name")
46+
raise RetrievalError(
47+
f"The expression {key!r} is not valid according to the configured pattern"
48+
)
4749
except Exception as exc:
4850
raise RetrievalError(f"variable evaluation error: {exc}")
4951
if not outputs:
50-
raise RetrievalError(f"variable {key!r} does not return any outputs")
52+
raise RetrievalError(f"expression {key!r} does not return any outputs")
5153

5254
# the returned outputs could be one of the following:
5355
# https://nbformat.readthedocs.io/en/latest/format_description.html#code-cell-outputs

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dependencies = [
3838
"ipython",
3939
"jupyter-cache>=0.5,<0.7",
4040
"nbclient", # nbclient version pinned by jupyter-client
41-
"myst-parser>=0.18.0",
41+
"myst-parser~=1.0.0",
4242
"nbformat~=5.0",
4343
"pyyaml",
4444
"sphinx>=4",
@@ -79,7 +79,7 @@ rtd = [
7979
"numpy",
8080
"pandas",
8181
"plotly",
82-
"sphinx-book-theme>=0.3",
82+
"sphinx-book-theme~=1.0.0",
8383
"sphinx-copybutton",
8484
"sphinx-design~=0.4.0",
8585
"sphinxcontrib-bibtex",

0 commit comments

Comments
 (0)