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.
The below cell will export to module1.py
because the argument module1
was passed to export.
The below cell will export to module2.py
because the argument module2
was passed to export.
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:
- run
nbdev_build_lib
from the command line. - run
nbdev.export.notebook2script
in python:
from nbdev.export import notebook2script
notebook2script()