Skip to content

Commit fd8f703

Browse files
committed
⬆️ UPGRADE: myst-parser v0.12.9
Minor upgrade with bug fixes
1 parent 1341c42 commit fd8f703

File tree

10 files changed

+68
-24
lines changed

10 files changed

+68
-24
lines changed

docs/examples/custom-formats.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ nb_custom_formats = {
7171
```
7272

7373
:::{important}
74-
It is necessary to use `jupytext<=1.4.0,>=1.5.0`, due to an incompatibility with the `myst-parser` version in `jupytext=1.4`.
74+
For full compatibility with `myst-nb`, `jupytext>=1.6.0` should be used.
7575
:::
7676

7777
For example:

docs/examples/interactive.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", size="s
6767
fig
6868
```
6969

70+
:::{important}
71+
72+
You may need to supply the `require.js` for plotly to display; in your `conf.py`:
73+
74+
```python
75+
html_js_files = ["https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"]
76+
```
77+
78+
:::
79+
7080
## Bokeh
7181

7282
Bokeh provides several options for interactive visualizations, and is part of the PyViz ecosystem. See

docs/use/markdown.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ For more information, see [the MyST-NB Sphinx extension documentation](index.md)
263263
## MyST Notebooks in Jupyter Book
264264

265265
In addition to using MyST Notebooks with Sphinx, you may also use them with the
266-
Jupyter Book project. See {doc}`jb:content-types/myst-notebooks`.
266+
Jupyter Book project. See {doc}`jb:file-types/myst-notebooks`.
267267

268268

269269
(myst-nb/jupyter-interfaces)=

myst_nb/execution.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from sphinx.application import Sphinx
2121
from sphinx.builders import Builder
2222
from sphinx.environment import BuildEnvironment
23-
from sphinx.util import logging
23+
from sphinx.util import logging, progress_message
2424

2525
from jupyter_cache import get_cache
2626
from jupyter_cache.executors import load_executor
@@ -273,14 +273,15 @@ def _stage_and_execute(
273273

274274
# can leverage parallel execution implemented in jupyter-cache here
275275
try:
276-
execute_staged_nb(
277-
cache_base,
278-
pk_list or None,
279-
timeout=timeout,
280-
exec_in_temp=exec_in_temp,
281-
allow_errors=allow_errors,
282-
env=env,
283-
)
276+
with progress_message("executing outdated notebooks"):
277+
execute_staged_nb(
278+
cache_base,
279+
pk_list or None,
280+
timeout=timeout,
281+
exec_in_temp=exec_in_temp,
282+
allow_errors=allow_errors,
283+
env=env,
284+
)
284285
except OSError as err:
285286
# This is a 'fix' for obscure cases, such as if you
286287
# remove name.ipynb and add name.md (i.e. same name, different extension)

myst_nb/nb_glue/domain.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ def key(self):
3030
return self.attributes["key"]
3131

3232
def copy(self):
33-
return self.__class__(
33+
obj = self.__class__(
3434
self.key, **{k: v for k, v in self.attributes.items() if k != "key"}
3535
)
36+
obj.document = self.document
37+
obj.source = self.source
38+
obj.line = self.line
39+
return obj
3640

3741
def create_node(self, output: dict, document, env):
3842
"""Create the output node, give the cell output."""

myst_nb/nodes.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ def renderer(self) -> str:
5252
return self._renderer
5353

5454
def copy(self):
55-
return self.__class__(
55+
obj = self.__class__(
5656
outputs=self._outputs,
5757
renderer=self._renderer,
5858
metadata=self._metadata,
5959
**self.attributes,
6060
)
61+
obj.document = self.document
62+
obj.source = self.source
63+
obj.line = self.line
64+
return obj

myst_nb/render_outputs.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from abc import ABC, abstractmethod
33
import os
44
from typing import List, Optional
5+
from unittest import mock
56

67
from importlib_metadata import entry_points
78
from docutils import nodes
@@ -19,6 +20,7 @@
1920
from jupyter_sphinx.utils import sphinx_abs_dir
2021

2122
from myst_parser.main import default_parser, MdParserConfig
23+
from myst_parser.docutils_renderer import make_document
2224

2325
from .nodes import CellOutputBundleNode
2426

@@ -118,7 +120,15 @@ def run(self):
118120
if "candidates" in node:
119121
continue
120122
col = ImageCollector()
121-
col.process_doc(self.app, node)
123+
124+
# use the node docname, where possible, to deal with single document builds
125+
docname = (
126+
self.app.env.path2doc(node.source)
127+
if node.source
128+
else self.app.env.docname
129+
)
130+
with mock.patch.dict(self.app.env.temp_data, {"docname": docname}):
131+
col.process_doc(self.app, node)
122132

123133

124134
class CellOutputRendererBase(ABC):
@@ -227,9 +237,25 @@ def parse_markdown(
227237
) -> List[nodes.Node]:
228238
"""Parse text as CommonMark, in a new document."""
229239
parser = default_parser(MdParserConfig(commonmark_only=True))
230-
parent = parent or nodes.container()
240+
241+
# setup parent node
242+
if parent is None:
243+
parent = nodes.container()
244+
self.add_source_and_line(parent)
231245
parser.options["current_node"] = parent
232-
parser.render(text)
246+
247+
# setup containing document
248+
new_doc = make_document(self.node.source)
249+
new_doc.settings = self.document.settings
250+
new_doc.reporter = self.document.reporter
251+
parser.options["document"] = new_doc
252+
253+
# use the node docname, where possible, to deal with single document builds
254+
with mock.patch.dict(
255+
self.env.temp_data, {"docname": self.env.path2doc(self.node.source)}
256+
):
257+
parser.render(text)
258+
233259
# TODO is there any transforms we should retroactively carry out?
234260
return parent.children
235261

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
python_requires=">=3.6",
5050
package_data={"myst_nb": ["_static/*"]},
5151
install_requires=[
52-
"myst-parser~=0.12.5",
52+
"myst-parser~=0.12.9",
5353
"docutils>=0.15",
5454
"sphinx>=2,<4",
5555
"jupyter_sphinx~=0.3.1",
@@ -73,11 +73,10 @@
7373
"numpy",
7474
"sympy",
7575
"pandas",
76-
# greater versions currently have a version conflict with myst-parser
77-
"jupytext<=1.4.0",
76+
"jupytext>=1.6.0",
7877
],
7978
"rtd": [
80-
"jupytext<=1.4.0",
79+
"jupytext>=1.6.0",
8180
"coconut~=1.4.3",
8281
"sphinxcontrib-bibtex",
8382
"ipywidgets",

tests/nb_fixtures/basic.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ cells:
135135
<document source="notset">
136136
<docinfo>
137137
<paragraph>
138-
<pending_xref refdomain="True" refexplicit="True" reftarget="before" reftype="myst" refwarn="True">
138+
<pending_xref refdoc="mock_docname" refdomain="True" refexplicit="True" reftarget="before" reftype="myst" refwarn="True">
139139
<inline classes="xref myst">
140140
a
141141

142-
<pending_xref refdomain="True" refexplicit="True" reftarget="after" reftype="myst" refwarn="True">
142+
<pending_xref refdoc="mock_docname" refdomain="True" refexplicit="True" reftarget="after" reftype="myst" refwarn="True">
143143
<inline classes="xref myst">
144144
b
145145
.

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# then then deleting compiled files has been found to fix it: `find . -name \*.pyc -delete`
1212

1313
[tox]
14-
envlist = py{36,37,38}-sphinx{2,3}
14+
envlist = py37-sphinx3
1515

1616
[testenv]
1717
# only recreate the environment when we use `tox -r`
@@ -31,4 +31,4 @@ deps =
3131
whitelist_externals = rm
3232
commands =
3333
clean: rm -rf docs/_build
34-
sphinx-build {posargs} -nW --keep-going -b html docs/ docs/_build/html
34+
sphinx-build -nW --keep-going -b {posargs:html} docs/ docs/_build/{posargs:html}

0 commit comments

Comments
 (0)