Home

Awesome

Custom Exporter for OCaml and the Jupyter NBConvert

Installing this Python project allow to convert Jupyter notebooks written with the OCaml Jupyter kernel directly to well-written .ml OCaml scripts. It solves this issue.

a) Test, and install locally

Clone this repository, test everything locally if you want, and then install it globally with:

$ python setup.py install  # for default Python
$ python3 setup.py install  # for Python3 if needed

Note: sudo right might be necessary:

$ sudo python3 setup.py install

b) Install directly from GitHub

This package can also be installed directly from GitHub with pip:

sudo pip install git+https://github.com/Naereen/Jupyter-NBConvert-OCaml

Check that you use pip2 or pip3 whether you installed Jupyter for Python 2 or Python 3. (You can of course install Jupyter-NBConvert-OCaml for both if you prefer!)

Use it

$ jupyter nbconvert --to ocaml A_Jupyter_notebook_with_OCaml_kernel.ipynb
$ ls A_Jupyter_notebook_with_OCaml_kernel.ml
...
$ ocaml A_Jupyter_notebook_with_OCaml_kernel.ml  # it works and comments are kept
...

To test it locally (in this folder), use this Makefile:

$ make convert_demo_ocaml_local
$ head -n7 demo_notebook_ocaml.ml
(*
This OCaml script was exported from a Jupyter notebook
using an open-source software (under the MIT License) written by @Naereen
from https://github.com/Naereen/Jupyter-NBConvert-OCaml
This software is still in development, please notify me of a bug at
https://github.com/Naereen/Jupyter-NBConvert-OCaml/issues/new if you find one
*)
...

Example

References

See the documentation I (Lilian Besson, @Naereen) used to write this small exporter.


:scroll: License ? GitHub license

MIT Licensed (file LICENSE). © Lilian Besson, 2017-2018.

Maintenance Ask Me Anything ! Analytics

ForTheBadge built-with-swag

ForTheBadge uses-badges ForTheBadge uses-git