You can use nbdev_test_nbs from nbdev to test notebooks. No customization is necessary for docs sites. This is aliased as nbdoc_test for convenience:
!nbdoc_test --help
To use nbdev_test_nbs, you must also define a settings.ini file at the root of the repo. For documentation based testing, we recommend setting the following variables:
- recursive = True
- tst_flags = notest
tst_flags = notest allow you to make commments on cells like #notest to allow tests to skip a specific cell. This is useful for skipping long-running tests. You can read more about this here.
recursive = True sets the default behavior of nbdev_test_nbs to True which is probably is what you want for a documentation site with many folders nested arbitrarily deep that may contain notebooks.
Here is this project's settings.ini (note that the recursive flag is set to False as this project is not a documentation site):
!cat ../settings.ini
from nbdev.test import nbdev_test_nbs
nbdev_test_nbs('test_files/example_input.ipynb', n_workers=0)
nbdev_test_nbs('test_files/', n_workers=0)