A quick demonstration on how to export code in nbdev

The below cell doesn't get exported to any module because there is no #export flag and is also hidden from the docs due to the #hide flag.

The below cell will export to demo.py, because there is no argument to export and the default was set to demo in the first cell.

func[source]

func()

The below cell will export to module1.py because the argument module1 was passed to export.

func2[source]

func2()

The below cell will export to module2.py because the argument module2 was passed to export.

func3[source]

func3()

To export code, first make sure a notebook exists for each module. If you don't do this, you will get an error. The notebooks can be minimal like the ones demonstrated in this repository

There are two choices for exporting notebooks:

  1. run nbdev_build_lib from the command line.
  2. run nbdev.export.notebook2script in python:
from nbdev.export import notebook2script
notebook2script()
Converted index.ipynb.
Converted module1.ipynb.
Converted module2.ipynb.