pre-commit hook for converting jupyter notebooks to multiple formats.
-
✅ Jupyter Notebooks are a great tool for doing data analysis
-
✅ You should treat them like code and keep them safe and available on a git repository
-
⚠️ Jupyter Notebooks format is not so great for doing code reviews or PRs -
⚠️ Jupyter Notebook default format is not the best for communicating with less code-literate teams
This commit hook does a couple of things for you:
-
Lets you choose from a set of available formats (currently Markdown, ReStructuredText and PDF)
-
When committing your notebook, it checks that it has an up to date companion format file
-
If theres none, it generates one for you
- A running Docker installation (generating different representations requires a lot of dependencies that are best encapsulated in a container)
-
Install pre-commit
-
Include notebook convert as one of your hooks in your
.pre-commit-config.yaml
:
repos:
- repo: https://github.com/fernandezpablo85/notebook_convert
rev: <check latest release>
hooks:
- id: notebook_convert
By default it will generate Markdown output, but you can also:
-
Generate reStructuredText files setting the
format
flag torst
-
Generate PDF files without input cells setting the
format
flag topdf
For example:
repos:
- repo: https://github.com/fernandezpablo85/notebook_convert
rev: <check latest release>
hooks:
- id: notebook_convert
args: [--format=pdf]
(If you want more than one representation just include the hook twice 🙃)
-
Run
pre-commit install
-
Enjoy