Skip to main content

Verbose nbdev (nbverbose)

An add-on to nbdev that allows for explicit parameter documentation

Install

pip install nbverbose

How to use

This library acts as an in-place replacement for nbdev's show_doc functionality, and extends it to allow for documentation of the inputs. It is also built on top of the docments functionality inside of fastcore: docs

Everything else with nbdev runs fine, and you should use normal nbdev conventions, however instead of doing from nbdev.showdoc import *, you should do from nbverbose.showdoc import *.

An example of what will happen can be found below

First we import the library:

from nbverbose.showdoc import *
The history saving thread hit an unexpected error (DatabaseError('database disk image is malformed')).History will not be written to the database.

Next we'll write a very basic function, that has a new way to document the inputs.

Rather than needing to have a very long doc string, your code can follow this declaration format. Spacing etc is not needed, just each parameter must be on a new line:

def addition(
    a:int, # The first number to be added
    b:(int, float)=2, # The second number to be added
):
    "Adds two numbers together"
    return a+b

As you can see, the documentation format is name followed by the type (as normal), but in a single-line comment afterwards you put a quick affiliated documentation string for it.

When you call the show_doc or doc functions, wrapping around addition, it will look something like so:

addition[source]

addition(a:int, b:(<class 'int'>, <class 'float'>)=2)

Adds two numbers together

Parameters:

  • a : <class 'int'>

    The first number to be added

  • b : (<class 'int'>, <class 'float'>), optional

    The second number to be added

We can see that our types are properly formatted. This even works in cases such as Union or List:

from typing import Union

def addition(
    a:int, # The first number to be added
    b:Union[int, float]=2., # The second number to be added
):
    "Adds two numbers together"
    return a+b

addition[source]

addition(a:int, b:Union[int, float]=2.0)

Adds two numbers together

Parameters:

  • a : <class 'int'>

    The first number to be added

  • b : typing.Union[int, float], optional

    The second number to be added

Any functions that normally don't follow this format can still work as well:

def addition(
    a:int,
    b:Union[int, float],
):
    "Adds two numbers together"
    return a+b

addition[source]

addition(a:int, b:Union[int, float])

Adds two numbers together

Parameters:

  • a : <class 'int'>

  • b : typing.Union[int, float]

def addition(a:int,b:Union[int, float]):
    "Adds two numbers together"
    return a+b

addition[source]

addition(a:int, b:Union[int, float])

Adds two numbers together

Parameters:

  • a : <class 'int'>

  • b : typing.Union[int, float]

{% include note.html content='The [source] button on these examples will not point to something existing. This is due to the fact that addition is not part of our library. This will work fine for anything done with your nbdev-built library.' %}

Metadata

Release files for nbverbose 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nbverbose 0.0.9
File Size Uploaded
nbverbose-0.0.9.tar.gz 13.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nbverbose 0.0.9
File Interpreter ABI Platform
nbverbose-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / nbverbose-0.0.9.tar.gz

Download URL nbverbose-0.0.9.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4e9085a27c5cd01ca654181ce32da5334ff656e41b8857e39048635a45869558
BLAKE2b-256 checksum
How to use checksums
684a3d2e622297380e3fe16b8f7aa4b73cadc4903759ad48de5dd51bbbf75cb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.0

Release files / nbverbose-0.0.9-py3-none-any.whl

Download URL nbverbose-0.0.9-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42a114b5a779954c34b62fc690aa76e1b33e6f03d5e9347405c2602298045ea3
BLAKE2b-256 checksum
How to use checksums
fc27ef8b2aebedab476d6a7e0212ca08785d27bad66bfd937023063dcb7ea995
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page