-
Notifications
You must be signed in to change notification settings - Fork 107
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
Use MyST-NB to render jupyter notebook and markdown files #196
Conversation
Codecov Report
@@ Coverage Diff @@
## development #196 +/- ##
============================================
Coverage 50.50% 50.50%
============================================
Files 17 17
Lines 1281 1281
Branches 280 280
============================================
Hits 647 647
Misses 581 581
Partials 53 53 Continue to review full report at Codecov.
|
So far this looks like a great upgrade to our docs. Thanks @weiji14! I seem to remember, vaguely, some conversation around the pros/cons of using numpydoc instead of Napoleon, but I'll have to see if I can find any notes on that (@norlandrhagen, do you remember?). My only major comment right now is that after a lot of back and forth we intentionally put the examples directory in the top level directory to make them easy to find. It's not intuitive for people to look in doc/source for them, even thought that's a "standard" home for them. I like the idea of them being rendered directly in the documentation, but also easy for people to find (since many find the repo before the docs). Thus, we should do some brainstorming around where they are available in the documentation (under "examples" or under "user guide"), where they reside in the repo, and what components of each notebook (if any besides the title) we want to show up in the left-hand menu bar, as well as how this ultimately relates to a user-contributed example gallery. |
Yes, I realize there was a lot of back and forth of moving the example notebooks, and I did try really hard to keep the *.ipynb files where they were in
Yes, an example gallery (as per #27) would be cool! I was catching up on the stalled issue at icesat2py/icepyx-gallery#1 the other day too. Maybe something to discuss for the meeting tomorrow (though I won't make it at 4am) or later this month. |
I'll try and put some work into this PR (and possibly #110) this week.
There's a stackoverflow question on it at https://stackoverflow.com/questions/36715801/difference-between-sphinxcontrib-napoleon-and-numpy-numpydoc#45009645. Just to quote it:
Functionally, they seem to do about the same thing (save us from writing in raw Sphinx syntax). I can revert the Napolean addition if you prefer to keep using NumpyDoc for icepyx?
Another idea would be to keep the |
Codecov Report
@@ Coverage Diff @@
## development #196 +/- ##
============================================
Coverage 51.91% 51.91%
============================================
Files 26 26
Lines 1855 1855
Branches 396 396
============================================
Hits 963 963
Misses 829 829
Partials 63 63 Continue to review full report at Codecov.
|
Finally getting into this PR again after way too long a hiatus. I rebased the branch onto the most recent development to avoid conflicts (hence the "new" commits). Thanks for your patience, @weiji14!
I personally like the look of Numpydoc over Napolean. From your notes and what I've read, it comes down mostly to personal preference which one we use... can we stick wiht Numpydoc for now? |
It's really weird to me that you can't use links to get to files outside of docs. It looks like it could be in the works, as this feature has been implemented for Markdown-style images and links. I played around with using |
I wanted to ping @choldgraf on this one :) Chris, do you have any thoughts on the examples management issue discussed above by @weiji14 and @JessicaS11? It seems that having flexibility on their location, for the purposes of regular use of the repo, is a reasonable use pattern, but it seems to clash with the rest of the build process a bit... A rather brutish hack would be to add a recursive copy operation against he examples dir at the start of the build (we could do it with hardlinks to go fast - But that feels crude, so perhaps @choldgraf has better ideas ;) |
../../../examples/ICESat-2_DAAC_DataAccess_Example | ||
example_notebooks/ICESat-2_DAAC_DataAccess2_Subsetting | ||
example_notebooks/ICESat-2_Data_Visualization_Example | ||
example_notebooks/ICESat-2_DEM_comparison_Colombia_working |
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.
Just wanted to add a general note here: with the notebooks now being rendered, they create a pretty long, confusing list that makes it hard to see what the actual example are. The examples have been updated and rearranged in #222, including some work to standardize headings, so we can make any additional changes to the examples themselves there and limit this PR to the doc generation itself.
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.
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.
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.
Hmmm one thing you could try is saving your notebooks as MyST markdown notebooks and then using an include directive in your docs, but that may not be ideal if you want them as ipynb. To be honest i think the most reasonable solution is to indeed add a copytree in the conf.py so that it gets moved over at build time, and then add that folder to your gitignore so it isn't in the repository more than once. But annoyingly Sphinx has no way to reference file outside the documentation root from the toctree |
Thanks @choldgraf for that feedback! I'll solicit some input from a few users, but I suspect that we can get away with the GeoPandas approach of putting some links and notes in the top level examples directory and then just house the notebooks themselves within the docs directory (which seems to be standard practice and I think made it a lot harder for scientists to find them before there was also a docs page where they were rendered!). |
@JessicaS11 in case it's helpful, here's my (very old) |
MyST-NB parses jupyter notebooks and markdown in Sphinx, thereby replacing nbsphinx (for .ipynb files) and recommonmark (for .md files). The powerful MyST (Markedly Structured Text) parser also allows much of the documentation to be written in Markdown instead of reStructuredText, which can make it easier for new folks wanting to make contributions to the documentation.
Use MyST markdown parser instead of reStructuredText parser.
Gets rid of autosummary toctree warnings, see https://stackoverflow.com/questions/12206334/sphinx-autosummary-toctree-contains-reference-to-nonexisting-document-warnings/43237890#43237890. Also need to add sphinx autosummary extension I think.
API docs didn't have proper links because *.ipynb files were generated instead of *.rst files, some buggy hardcoding apparently. Workaround is to put the ".rst" line first in Sphinx's conf.py. Also removed a numpydoc config, and ensure API docs are generated to doc/source/_icepyx (which is gitignored).
Put the rendered ICESat-2_DAAC_DataAccess_Example jupyter notebook in the User Guide! No need to visit GitHub to see the jupyter notebook anymore!
See https://myst-parser.readthedocs.io/en/v0.13.6/using/syntax-optional.html#linkify. Converts https URLs into clickable links, e.g. those at the end of the Code of Conduct page.
See https://myst-parser.readthedocs.io/en/v0.13.6/using/howto.html#automatically-create-targets-for-section-headers. Fixes WARNING: duplicate label xxx, other instance in yyy (mostly in the changelog page).
@weiji14 When you get a chance (no rush - January is fine!) can you look this PR over again since I was the last one to make a bunch of edits? Then I can give it an approving review and we can merge it. Note that I created Issue #257 to improve the notebook organization after this initial PR to get the functionality there. |
Just from a quick scan, I do feel like there's too many nested headings. Do you think it's possible to remove the 'Example notebooks' level, and just have everything under 'Examples'? I'll try and give this a closer look next week after AGU is over. Too many things on my plate right now... |
Done - great catch.
No rush - I just wanted to document it was ready for the next step. |
Prevents `WARNING: Non-consecutive header level increase; 0 to 2 [myst.header]` when building docs.
Fixes `WARNING: duplicate label getting_started/example_notebooks/working_with_icesat-2_data_variables:example 1: choose variables, other instance in ...`
Increase visibility of the jupyter notebook examples on the readthedocs page.
Hi @JessicaS11, I've made a few more minor updates to fix some Sphinx doc build warnings. Also, I've moved the notebook examples into a dedicated section on the sidebar to improve visibility: Let me know if you're ok with this, otherwise I can revert commit a161b42 to have the examples be nested under Getting Started -> Examples as before: |
I really like this change, but I'm concerned that it will make the menu bar long and diluted as we add new examples. To give us time to come up with an plan (perhaps we can have a few main categories of example type that get listed on the menu bar, with individual examples listed within?), I reverted the change in this PR and after we merge will create a new branch with it that we can keep working on. That will also have your commit to increase the heading levels, since we need to do a go-through of the examples to standardize heading levels anyway. |
This reverts commit db480e7.
234944e
to
77a93b1
Compare
Render the icepyx example jupyter notebooks directly at https://icepyx.readthedocs.io/en/development (i.e. without having to go to GitHub)!
Preview at https://icepyx--196.org.readthedocs.build/en/196/getting_started/examples.html
This is done using MyST-NB which parses jupyter notebooks (or markdown) in Sphinx. MyST-NB also acts as a replacement for:
The powerful MyST (Markedly Structured Text) parser also allows much of the documentation to be written in Markdown instead of reStructuredText, which can make it easier for new folks wanting to make contributions to the documentation.
This PR also replacesEdit: sticking with numpydoc for now as per #196 (comment)numpydoc
with Sphinx's built-inNapolean
extension (they practically do the same thing).P.S. Context for this Pull Request is to eventually revamp the front-facing docs page as per #110. This is really just a maintenance PR laying the groundwork by modernizing some of the Sphinx documentation dependencies, and fixing some issues along the way.