Skip to main content

A helpful extension for nbdev geared towards better documentation

Project description

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 *

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'> None

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

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'> None

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

{% 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.' %}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nbverbose-0.0.4.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

nbverbose-0.0.4-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file nbverbose-0.0.4.tar.gz.

File metadata

  • Download URL: nbverbose-0.0.4.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for nbverbose-0.0.4.tar.gz
Algorithm Hash digest
SHA256 bbaf40bead5481ac499bb848571a2aa469b055aa536d539805450aa1bdc4dfee
MD5 b36acd2ff7639c34c4d3d4e6642f2db5
BLAKE2b-256 5fdcb5085b8a3ccc87c5b3e1764943b79fb8b6303a05c47e0d26bb5ec6c04f51

See more details on using hashes here.

File details

Details for the file nbverbose-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: nbverbose-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for nbverbose-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6ac544309260c68978013e5ebd3b581e3bbad05226a8f7a71150b8a2de8d1f5a
MD5 5a74ec739446dbaf7809eca001419805
BLAKE2b-256 892f2a9def2d12900e083f1c388bb025aa877e38078b1ae4b31bf9bcc52fc572

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page