Modular fastship
How to use fastship's various tools separately
While ship-new --nb gets you started with everything you need to create a delightful Python package, you can also use each of fastship's components listed below on their own. You might find this useful if you're porting a large system over to fastship, documenting an existing code base, or if you'd like to customize the fastship workflow for your own project. Note that all of the commands below work without a pyproject.toml file unless otherwise noted.
Document existing code: show_doc
fastship allows you to document existing code, even code that is not written in fastship! fastship.showdoc.show_doc allows you to render beautiful API documentation in notebooks and on Quarto sites. For example, you can render API documentation for numpy.all like this:
from fastship.showdoc import show_doc
from numpy import all
show_doc(all)
all
all (a, axis=None, out=None, keepdims=<no value>, where=<no value>)
Test whether all array elements along a given axis evaluate to True.
| Type | Default | Details | |
|---|---|---|---|
| a | array_like | Input array or object that can be converted to an array. | |
| axis | NoneType | None | Axis or axes along which a logical AND reduction is performed. The default ( axis=None) is to perform a logical AND over allthe dimensions of the input array. axis may be negative, inwhich case it counts from the last to the first axis. .. versionadded:: 1.7.0 If this is a tuple of ints, a reduction is performed on multiple axes, instead of a single axis or all the axes as before. |
| out | NoneType | None | Alternate output array in which to place the result. It must have the same shape as the expected output and its type is preserved (e.g., if dtype(out) is float, the resultwill consist of 0.0's and 1.0's). See :ref: ufuncs-output-type for moredetails. |
| keepdims | _NoValueType | <no value> | If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. If the default value is passed, then keepdims will not bepassed through to the all method of sub-classes ofndarray, however any non-default value will be. If thesub-class' method does not implement keepdims anyexceptions will be raised. |
| where | _NoValueType | <no value> | Elements to include in checking for all True values.See ~numpy.ufunc.reduce for details... versionadded:: 1.20.0 |
| Returns | ndarray, bool | A new boolean or array is returned unless out is specified,in which case a reference to out is returned. |
show_doc automatically parses docstrings that are written in the numpy style. For more information read here.
Testing notebooks: ship-test
Testing notebooks can be very useful outside of fastship, especially if you are documenting an existing code base and want to incorporate tests for your docs. The ship-test CLI utility allows you to accomplish this:
You can test an individual notebook with the terminal command:
ship-test notebook.ipynb
…or a folder of notebooks:
ship-test tests/
Export code to modules: nb_export
You can export a notebook to a module with the Python function:
nb_export('notebook.ipynb', 'pkg')
…provided the notebook specifies a default_exp directive at the top, and export directives above each cell to be exported. We recommend including this in a code cell at the bottom of your notebook for convenience.
Jupyter-git integration
Jupyter and Git don't normally play well together, especially for notebook diffs and merge conflicts. Configure fastship's Git diff and merge drivers (ship-diff-driver and ship-merge) in your Git config and .gitattributes, and optionally enable Jupyter pre-save cleaning — see Git-Friendly Jupyter for the exact setup.
You can also call any of the underlying commands directly:
ship-cleanship-diffship-diff-drivership-mergeship-fix
To configure your own hooks, Check out the pre-commit hooks tutorial.
Python packaging
fastship.release provides utilities for PyPI publishing (uv), tag-driven CI releases (Rust, Zig, npm), and GitHub releases. See the fastship.release docs for details.