Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨♻️‼️ Rewrite myst-nb #380

Merged
merged 88 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
d7fe4b6
⬆️ UPGRADE: myst-parser v0.16.1
chrisjsewell Dec 19, 2021
6854166
Move jupyter-sphinx/ipywidgets functionality into jsphinx
chrisjsewell Dec 19, 2021
815f6fc
move nodes from jsphinx -> nodes
chrisjsewell Dec 20, 2021
83cccbd
ipywidgets url: unpkg -> jsdelivr
chrisjsewell Dec 21, 2021
71bec09
Move sphinx extension to separate module
chrisjsewell Dec 21, 2021
c07109f
updates from myst-parser master branch
chrisjsewell Jan 2, 2022
b33ea1e
Module ansi_lexer -> lexer, and add entry points
chrisjsewell Jan 2, 2022
02c3494
Initial implementation of docutils parser
chrisjsewell Jan 2, 2022
11188c2
Document render methods
chrisjsewell Jan 2, 2022
d39d2f4
modularise docutils code
chrisjsewell Jan 2, 2022
27ec5f7
Add execution data to the document
chrisjsewell Jan 2, 2022
248e7af
Initial implementation of new sphinx parser
chrisjsewell Jan 3, 2022
73ea5ed
Improve logging mechanism
chrisjsewell Jan 3, 2022
422f2e7
Handle mime type selection in sphinx
chrisjsewell Jan 3, 2022
fa395a6
rename logger classes
chrisjsewell Jan 3, 2022
88f2db6
Add deprecation pathway for legacy config names
chrisjsewell Jan 3, 2022
30e29b6
Add notebook reading of custom formats
chrisjsewell Jan 4, 2022
7c93581
Improve execute code
chrisjsewell Jan 4, 2022
7148c5f
Add UnexpectedCellDirective
chrisjsewell Jan 4, 2022
5023034
Move coalesce_streams to new module
chrisjsewell Jan 4, 2022
b0c2183
Handle ipywidgets
chrisjsewell Jan 4, 2022
478b550
Successfully build the docs (with warnings)
chrisjsewell Jan 5, 2022
8ce2d8c
re-add toggle-button integration
chrisjsewell Jan 5, 2022
c21ab70
Replace all old code
chrisjsewell Jan 5, 2022
ab03041
pre-commit fixes
chrisjsewell Jan 5, 2022
3e54270
re-implement `execution_excludepatterns`
chrisjsewell Jan 5, 2022
672fea0
skip glue outputs for now
chrisjsewell Jan 5, 2022
4dfb54b
Fix execution tests
chrisjsewell Jan 6, 2022
2bb55e2
fix more tests
chrisjsewell Jan 6, 2022
95e4cf8
fix more tests
chrisjsewell Jan 6, 2022
26d8f40
fix collector
chrisjsewell Jan 6, 2022
2c38c16
typo fix
chrisjsewell Jan 6, 2022
0a06ecf
And notebook level overrides of configuration
chrisjsewell Jan 6, 2022
156d389
Add per-cell configuration
chrisjsewell Jan 6, 2022
ca38f6e
Add figure code cell output rendering
chrisjsewell Jan 6, 2022
6573461
Do not create code cell container, if removing input & output
chrisjsewell Jan 6, 2022
39a2b10
Fix more tests
chrisjsewell Jan 7, 2022
24604f6
Render raw cells
chrisjsewell Jan 7, 2022
3a19193
initial glue implementation
chrisjsewell Jan 7, 2022
baed2c6
Add some docstrings
chrisjsewell Jan 7, 2022
91232e8
add MimeData data class
chrisjsewell Jan 7, 2022
3b9010d
Add most glue functionality
chrisjsewell Jan 7, 2022
b67d219
Update documentation
chrisjsewell Jan 8, 2022
1e54d1e
Update test for sphinx 3
chrisjsewell Jan 8, 2022
b1bfa59
Test fixes
chrisjsewell Jan 8, 2022
ed68851
test fix
chrisjsewell Jan 8, 2022
766ee43
Output displayed glue variables
chrisjsewell Jan 8, 2022
c3dc375
fix docs
chrisjsewell Jan 8, 2022
19e3204
fix sphinx_book_theme integration
chrisjsewell Jan 8, 2022
4130489
Updates from myst-parser
chrisjsewell Jan 9, 2022
7929b65
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 9, 2022
bcc711c
pre-commit fix
chrisjsewell Jan 9, 2022
aa6e502
Update pytest_param_files
chrisjsewell Jan 9, 2022
daab4d2
Add `render_markdown_format` configuration
chrisjsewell Jan 10, 2022
5883982
improve glue code
chrisjsewell Jan 11, 2022
0d27b3e
Improve registering of per-page javascript
chrisjsewell Jan 11, 2022
e87cf4c
Remove uneeded jupyter_sphinx CSS
chrisjsewell Jan 11, 2022
1dd2e64
In sphinx, cache glue keys (on env)/outputs(on file)
chrisjsewell Jan 11, 2022
fff43fa
Update docs/use/formatting_outputs.md
chrisjsewell Jan 11, 2022
64c6d2b
remove unnecessary header in glue.md
chrisjsewell Jan 11, 2022
a7a7b32
Improve docutils output of CSS
chrisjsewell Jan 12, 2022
d71d0cf
remove no longer used method
chrisjsewell Jan 12, 2022
cff8ebc
rename render_unknown -> render_unhandled
chrisjsewell Jan 12, 2022
c20db70
windows fix
chrisjsewell Jan 12, 2022
51bb988
minor updates
chrisjsewell Jan 13, 2022
ac493b0
pin ipython to <8
chrisjsewell Jan 13, 2022
5cc68ef
pin ipython to <8 for testing
chrisjsewell Jan 13, 2022
fe1529c
Fix glue line warnings
chrisjsewell Jan 13, 2022
0234f5d
Merge branch 'master' into refactor-mystnb
chrisjsewell Mar 1, 2022
cddf60d
use myst-parser v0.17.0
chrisjsewell Mar 1, 2022
7256cc0
Update test_parser.sphinx3.xml
chrisjsewell Mar 2, 2022
61d8d35
Update tests to ipython v8
chrisjsewell Mar 2, 2022
b543351
Add typing
chrisjsewell Mar 2, 2022
280c119
fix docs
chrisjsewell Mar 2, 2022
c354d0b
Update docs
chrisjsewell Mar 2, 2022
9b3bf64
Update jupyter-cache
chrisjsewell Mar 2, 2022
fcc5ace
Update docutils_.py
chrisjsewell Mar 2, 2022
437de73
Move to flit, replace attrs
chrisjsewell Apr 17, 2022
e8daf94
Update tests.yml
chrisjsewell Apr 17, 2022
e815a4b
Update tests.yml
chrisjsewell Apr 17, 2022
faf0367
Update tests.yml
chrisjsewell Apr 17, 2022
7b71185
remove 3.10 for now
chrisjsewell Apr 17, 2022
eb4a92c
Restructure modules
chrisjsewell Apr 18, 2022
14cab36
Fix typing
chrisjsewell Apr 19, 2022
1e5450a
stuff
chrisjsewell Apr 19, 2022
cd60fe6
Add (limited) cross-document gluing
chrisjsewell Apr 19, 2022
89924b9
Add `MimeRenderPlugin`
chrisjsewell Apr 20, 2022
c45bdab
add validator
chrisjsewell Apr 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]
sphinx: [">=3,<4", ">=4,<5"]
include:
- os: windows-latest
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,12 @@ dmypy.json
.pyre/

# Jupyter Cache
docs/.jupyter_cache
.jupyter_cache

# OSX
.DS_Store

.vscode/

todos.md
_archive/
25 changes: 14 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,20 @@ repos:
- id: flake8
additional_dependencies: [flake8-bugbear==21.3.1]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910-1
hooks:
- id: mypy
args: [--config-file=setup.cfg]
additional_dependencies:
- myst-parser~=0.14.0
files: >
(?x)^(
myst_nb/parser.py|
)$
# - repo: https://github.com/pre-commit/mirrors-mypy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining why this section is commented out, and when we should un-comment it? (or, can we just delete it?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

# rev: v0.910-1
# hooks:
# - id: mypy
# args: [--config-file=setup.cfg]
# additional_dependencies:
# - importlib_metadata
# - myst-parser~=0.16.1
# - "sphinx~=4.3.2"
# - types-PyYAML
# files: >
# (?x)^(
# myst_nb/[^/]+.py|
# )$

# this is not used for now,
# since it converts myst-nb to myst_nb and removes comments
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ exclude codecov.yml
include LICENSE
include CHANGELOG.md
include README.md
include myst_nb/_static/mystnb.css
include myst_nb/static/mystnb.css
66 changes: 60 additions & 6 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,70 @@
Python API
==========

.. toctree::
:maxdepth: 2
The parsing of a notebook consists of a number of stages, with each stage separated into a separate module:

nodes
render_outputs
1. The configuration is set (from a file or CLI)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very helpful description of the whole process, I wonder if we could put this in a place where it is more discoverable? Can do that in a follow up though

2. The parser is called with an input string and source
3. The parser reads the input string to a notebook node
4. The notebook code outputs are potentially updated, via execution or from a cache
5. The notebook is "pre-processed" in-place (e.g. to coalesce output streams and extract glue outputs)
6. The notebook is converted to a Markdown-It tokens syntax tree
7. The syntax tree is transformed to a docutils document AST (calling the renderer plugin)
8. The docutils document is processed by docutils/sphinx, to create the desired output format(s)

Miscellaneous
Configuration
-------------

.. autoclass:: myst_nb.ansi_lexer.AnsiColorLexer
.. autoclass:: myst_nb.configuration.NbParserConfig
:members:

Parsers
-------

.. autoclass:: myst_nb.docutils_.Parser
:members:

.. autoclass:: myst_nb.sphinx_.Parser
:members:

Read
----

.. autoclass:: myst_nb.read.NbReader
:members:

.. autofunction:: myst_nb.read.create_nb_reader

.. autofunction:: myst_nb.read.is_myst_markdown_notebook

.. autofunction:: myst_nb.read.read_myst_markdown_notebook

Execute
-------

.. autoclass:: myst_nb.execute.ExecutionResult
:members:

.. autofunction:: myst_nb.execute.execute_notebook

Pre-process
-----------

.. autofunction:: myst_nb.preprocess.preprocess_notebook

Render plugin
-------------

.. autoclass:: myst_nb.render.MimeData
:members:

.. autoclass:: myst_nb.render.NbElementRenderer
:members:

Lexers
------

.. autoclass:: myst_nb.lexers.AnsiColorLexer
:members:
:undoc-members:
:show-inheritance:
26 changes: 0 additions & 26 deletions docs/api/nodes.rst

This file was deleted.

30 changes: 0 additions & 30 deletions docs/api/render_outputs.rst

This file was deleted.

Loading