Writing collaborative libraries with nbdev
pip install nbagile
- When exporting source code using
docments, attach and format the docstring to Numpy format
- Export tests and throw them into a pytest-compatible file format
- Make documentation run on Sphynx
- Tests are exported to a
testsfolder, source code to a source code folder, and Markdown/Sphynx documentation to a
- Individual notebooks can then be recreated from these three items
Using the CLI
nbdev_ commands with
nbagile_ to use it's capabilities.
nbagile_build_lib: Exports code and converts it to black-style + NumPy docstrings
nbagile_diff_nbs: A special version of
nbdev_diff_nbsto support how nbagile works
nbagile_build_docs: Builds the docs using nbverbose
Exporting code from
docments to NumPy
def addition( a:int, # The first number to add b:(int,float), # The second number to add ) -> int: # The sum of a and b "Adds a and b" return a+b
But this is not the commonly accepted way of documenting our code, and as a whole looks quite ugly.
nbagile supports building your nbdev built libraries to instead automatically convert this code into a more NumPy-styled documentation string and definition, with the added bonus of it mimicing the Black format:
def addition(a,b): """Adds a and b Parameters ---------- a : int The first number to add b : (int,float) The second number to add Returns ---------- int The sum of a and b """ return a+b
This works for functions, classes, as well as functions wrapped around decorators.
__all__ for nbdev
If you are not a fan of nbdev's
__all__ format in each file, there is an additional setting you can add to your
If set to
False, you won't get the
__all__ being generated in each python file
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.