PyWEB is a simple Python3 program which would allow you to tangle and weave your Jupyter notebooks.
Jupyter Notebooks are a very basic yet simple and effective implementation of Knuth's Literate Programming
style which he invented back in 1980's. In literate programming style, you write down your ideas and code
intermingled with each other in a plain text document. This document represents the "web" of your ideas and
code. Then, source files which the compiler can parse are produced by tangling the web which involved
extracting code from the text file. Documentation for the code is generated by a process called weaving.
You cannot say that Knuth's invention is useless: the original TeX
engine was completely written in literate programming style using his Web programming system. It never
became a fad for this approach of writing programs appears to be quite tedious (and corporates always prefer
bad products which are shipped quickly and improved iteratively over one-shot great products).
In any case, more than 30 years later, Jupyter notebooks are being widely used both in academia and in the
industry to write well organised, and documented computer code, codes which are used to train LLMs or to
detect gravitational waves.
Given the importance of Jupyter Notebooks, I decided to write a simple program in Python which would allow me
to extract source code and generate documentation. I call it PyWEB.
Yes, this name has been taken by numerous other products, but anyways!! I had fun writing this teeny-weeny
code and that's the main point.
You can run pyweb by typing python3 pyweb.py
in the terminal.
To tangle a file, i.e., to produce a source file from the JSON making up the Jupyter notebook, the syntax is:
python3 pyweb.py -t path/to/notebook/name-of-the-notebook extension-without-dot src-name path/to/src
To weave a file, i.e., to produce a documentation out of you Jupyter notebook, the syntax is:
python3 pyweb.py -t path/to/notebook/name-of-the-notebook format dco-name path/to/doc
PyWEB uses Jupyter's nbconvert
utility to produce documentation.
python3 pweb.py -t "Notebooks/Simple Bootloader.ipynb" asm "boot" boot/
python3 pweb.py -t "Notebooks/Linear Regression.ipynb" pdf "Linear Regression" Documentation/