Contributing
Contributions are welcome from the community. Questions can be asked on the
issues page. Before creating a new issue, please take a moment to search
and make sure a similar issue does not already exist. If one does exist, you
can comment (most simply even with just a :+1:) to show your support for that
issue.
If you have direct contributions you would like considered for incorporation into the project you can fork this repository and submit a pull request for review.
Adding a Notebook
Fork the repository
Install the
docs/docs-environment.ymlpython environment, which has a few extra packages for building the HTML documentation.See the existing
notebooks/for examples.When developing the notebook, pay attention to the markdown header levels:
#for the title, which will appear in the Table of Contents tree on the left, and as the caption for the thumbnail.##for subheaders, which will also appear in the Table of Contents tree.###and####between subheaders, as needed.
For now, each notebook title begins with the number (e.g. “01: Title”).
Including output or not:
Currently, output in the exercise notebooks (not in the
solutions/subfolders) should be cleared prior to submitting a PR, unless the notebook is listed as excepted innotebooks/clear_all_notebooks.py. The.github/workflows/notebook-output.yamlworkflow will check for output in non-solution notebooks.
Notebook execution
Notebooks that don’t have saved output will be executed by
nbsphinx, so that the output is rendered in the HTML docs.Excessive errors can be quieted by importing
warningsat the top, and then includingwarnings.filterwarnings("ignore")within the offending cell.Alternatively, screen output for a given cell can be turned off by including
%%captureat the top.
Testing
The
.github/workflows/test.yamlworkflow will check for successful notebook execution.If your notebook has intentional errors, consider just showing the error in a markdown block (wrapped in python`````` so that the syntax gets highlighted).
Otherwise, include the notebook in the
xfail_notebookslist intests/test_notebooks.py, so that the notebook gets marked as expected to fail (and doesn’t fail the test workflow).
Adding the notebook to the example gallery
Edit the
copy_notebookslist indocs/conf.pyto add the notebook. This will copy the notebook to thedocs/notebooksfolder so that it can be rendered in the documentation.Edit
part0.rst,part1.rstorbonus_examples.rstto add the notebook to the appropriate example gallery.At the command line run
make -C docs htmlCheck the results by entering
file:///<path to your notebook>into a web browserBy default, the thumbnail icon is made from the last plot (if one exists). Otherwise, see the nbsphinx instructions on thumbnails to use another plot or include a static thumbnail.