Run nbsqueeze from the command line
For all my coding work, I use the awesome Python package nbdev. Thanks to this software learned how to efficiently use Github and how to publish my own Python packages (like this one!) with beautiful documentation all rendered from a bunch of Jupyter notebooks. Ultimate freedom of expression! Now, I am pushing the nbdev machinery to it’s limits due to the large amount of plots with high resolution images that I need to embed in my documentation.
In my work flow, I need to squeeze the figures out of all Jupyter notebooks in a notebooks project folder simultaneously with a single command. For this reason I created a console command nbsqueeze that can executed from the terminal (a.k.a. command prompt) in the root folder of a project. Simply type this:
$ nbsqueeze
The command assumes the your current working directory contains a folder named either nbs or notebooks that contain all your Jupyter notebooks. The command first identifies all figure images that have already been created, and then deletes all other obsolete image files. Subsequently it squeezes all figures from all notebooks.
squeeze
squeeze (glob_ptrn='n*b*s/*.ipynb', verbose=False, overwrite=True)
Extract all embedded images from all notebooks in notebooks subdirectory.
clean_imdir
clean_imdir (nb_path, verbose=False)
Remove orphant image files corresponding to notebook nb_path that are not linked.
find_links
find_links (nb_path)
Find existing links to png images in notebook nb_path.