A nbdev 'Hello World!' tutorial
%load_ext autoreload
%autoreload 2

Functions

Add a function

say_hello[source]

say_hello(to)

Say hello to somebody

Use an example to prove it works

say_hello("Diana")
'Hello Diana!'

Examples can output plots, images, etc, and they'll all appear in your docs, e.g.:

from IPython.display import display,SVG
display(SVG('<svg height="100"><circle cx="50" cy="50" r="40"/></svg>'))

We can also include some tests

assert say_hello("Jeremy")=="Hello Jeremy!"

Classes

Add a class

class HelloSayer[source]

HelloSayer(to)

Say hello to to using say_hello

Show the documentation for HelloSayer

HelloSayer.say[source]

HelloSayer.say()

Do the saying

Do a test for the class

o = HelloSayer("Alexis")
o.say()
'Hello Alexis!'