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

Use nbsphinx and Jupyter notebooks as user guide instead of .rst files + data module #236

Merged

Conversation

hakonanes
Copy link
Member

@hakonanes hakonanes commented Oct 22, 2020

Signed-off-by: Håkon Wiik Ånes hwaanes@gmail.com

Description of the change

  • Add nbsphinx (https://nbsphinx.readthedocs.io/en/0.8.0/) dependency when building the docs (i.e. the user only has to install it if pip install kikuchipy[doc/dev] is used). nbsphinx reformats Jupyter notebooks into rst files to include in doc/index.rst.
  • Replace the doc/pattern_processing.rst file with a doc/pattern_processing.ipynb file containing the exact same information, only plotting and code cells are displayed differently.
  • Make kikuchipy.data module public to simplify making of the user guide.

If this works well and looks OK, the plan is to remove the other user guide pages and only use Jupyter Notebooks.

A major drawback is that intersphinxing in notebook markdown cells is limited, meaning we have to insert the exact URLs for other packages, and write

`[kikuchipy.signals.EBSD](reference.rst#kikuchipy.signals.EBSD)`

where we previously could write

:class:`kikuchipy.signals.EBSD`

I'll write these things down in the contributing guide as this PR progresses.

A huge win is the automatic running of the notebook (and thus testing), and the easy and intuitive way in which the user guide can be created.

Progress of the PR

  • Finish the pattern processing notebook
  • The processing notebook doesn't require a large data set, so we should finally make the kikuchipy.data module work like skimage.data (https://github.com/scikit-image/scikit-image/tree/master/skimage/data) for a (3, 3, 60, 60) shape Nickel data set
    Use the kikuchipy.data.nickel_small dataset in tests. For another PR.
    Figure out a clean way to download data to be used by the notebooksLet's put this off for now, and try to build a smart data module instead
    ~Set up automatic build of the notebooks with data downloading preferably done only once for all notebooks (same data used by all notebooks)~The notebooks are converted to reST files by nbsphinx upon doc builds.
  • Add notebook documentation tips in the contributing guide

For another time:

  • MyBinder
  • Notebook timings

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    the unreleased section in doc/changelog.rst.

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes hakonanes added documentation This relates to the documentation maintenance This relates to package maintenance labels Oct 22, 2020
@hakonanes hakonanes added this to the v0.3.0 milestone Oct 22, 2020
@hakonanes hakonanes self-assigned this Oct 22, 2020
@hakonanes hakonanes marked this pull request as draft October 22, 2020 19:58
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes hakonanes changed the title Use nbsphinx and Jupyter notebooks as userguide instead of .rst files Use nbsphinx and Jupyter notebooks as user guide instead of .rst files Oct 23, 2020
@hakonanes
Copy link
Member Author

I've come to really enjoy two things about writing a user guide in a notebook instead of plain text files:

  • the immediate feedback when executing a notebook cell instead of having to build the documentation to see the result of a change in a .rst file
  • the fact that the notebook is run by nbsphinx when building the HTML docs (make html), ensuring errors are caught

A drawback I see is still linking and use of references (like [Gonzalez2017]_). We need to check links as part of the doc build process.

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes
Copy link
Member Author

hakonanes commented Oct 23, 2020

I couldn't find a way to check links automatically... So for now, we'll have to check them manually.

Edit: make -b html linkcheck (https://www.sphinx-doc.org/en/master/man/sphinx-build.html?highlight=linkcheck)...

@hakonanes hakonanes changed the title Use nbsphinx and Jupyter notebooks as user guide instead of .rst files Use nbsphinx and Jupyter notebooks as user guide instead of .rst files + data module Oct 23, 2020
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes
Copy link
Member Author

Pushed this branch up to the kikuchipy repo to see if Readthedocs builds the documentation OK: https://kikuchipy.org/en/add-pattern-processing-notebook-with-nbsphinx/

@hakonanes
Copy link
Member Author

The pattern processing notebook can be viewed on nbviewer: https://nbviewer.jupyter.org/urls/kikuchipy.org/en/add-pattern-processing-notebook-with-nbsphinx/pattern_processing.ipynb

However, none of the internal doc intersphinx links work...

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
@hakonanes hakonanes marked this pull request as ready for review October 23, 2020 23:59
@hakonanes hakonanes merged commit fc05696 into pyxem:master Oct 23, 2020
@hakonanes hakonanes deleted the add-pattern-processing-notebook-with-nbsphinx branch October 23, 2020 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This relates to the documentation maintenance This relates to package maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant