-
Notifications
You must be signed in to change notification settings - Fork 86
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
Draft of text-based notebooks #116
Conversation
Some thought needs to be put into how people might use this with jupytext, i.e. if there is both a |
Fantastic - I think this is one of the final pieces in the puzzle! re: extension preference, this is something that we could also control at the |
Great work @chrisjsewell. (Regarding the source-for-build policy at the jupyter-book level, it is a potential source of confusion isn't it? Given that most people are pretty careless when it comes to reading the documentation. Perhaps it's worth having a clear statement of the default (either md or ipynb), although still allowing the user to customize. A natural default would be to build from the md whenever they exist. That will never trouble people who use only ipynb.) |
The correct line numbers are now reported for these text-based notebooks 😄 Shall I also convert some more of the notebooks in the documentation to markdown files? Obviously the markdown ones are a lot easy to edit (and better for git diffs), but probably also want some ipynb in their for example. |
I'm +1 for the idea. Let's leave at least one ipynb file in there, but I'm fine with almost all of them being |
@jstac I agree - my intuition is that "markdown should take precedence by default". That way, we won't run into issues if, for example, somebody edits content directly on a github repository, which isn't really possible to do with the ipynb files |
Yes, "markdown takes precedence whenever it exists" is an easy rule for the user to remember. |
Yep that would be the preference. However, as mentioned above sphinx doesn't handle this very well (it wasn't really written with multiple file types in mind). I've added the A few edge cases:
This is only because |
2ffaa69
to
a9493c2
Compare
Added 'fixes' for these cases |
All the documentation notebooks are now markdown files, and I have added a footnote with download links for the files as both markdown and (executed) notebooks, e.g. https://318-241268229-gh.circle-artifacts.com/0/html/use/basic.html#download |
Rather than having a global variable, we save the exclude paths in the sphinx env and use a seperate function `is_valid_exec_file`. Also added tests
60130ff
to
09ede44
Compare
This can be merged if people are happy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few minor comments but this looks great in general. I think one small round of tweaks and then we should merge!
Sphinx using the MyST parser.[^download] | ||
|
||
[^download]: This notebook can be downloaded as | ||
**{jupyter-download:notebook}`basic`** and {download}`basic.md` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason to use jupyter-download
here and not just download
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the file is taken from the jupyter_execute
folder, i.e. the post-execution notebook, not the source folder as download
looks at. I guess see jupyter-sphinx
for the actual logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right - I remember now, thanks
|
||
:raises MystMetadataParsingError if the metadata block is not valid JSON/YAML | ||
|
||
NOTE: we assume here that all of these directives are at the top-level, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty big assumption, no? So myst-nb will not support nested directives?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all directives, just {code-cell}
. This is necessary for compliance with round trip conversion with notebooks, as obviously you can't have a code cell nested in a markdown cell. When I say 'assume`, I mean we just ignore any nested code cells, which will, if present, then raise an error on the sphinx parse, because it won't have a directive associated with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - that makes sense then, since contents of {code-cell}
s don't support myst-markdown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep thats the one 'compromise' we make, in terms of treating the whole file as a notebook (rather than 'extracting' notebooks from files, like jupyter-sphinx does): you can't do something like
````{note}
```{code-cell}
a = 1
```
````
with the benefit of being abled to treat them exactly the same a standard notebooks; using top-matter for metadata and integrating them with jupyter-cache etc.
Co-Authored-By: Chris Holdgraf <[email protected]>
boom! I am very excited, will test out today |
Builds on top of #107. In this implementation
myst-nb
replacesmyst-parser
as the markdown parser and tests all files for a "notebook signature".Documented in https://306-241268229-gh.circle-artifacts.com/0/html/use/markdown.html