How jupyter/nbformat works
Project type and purpose
• nbformat is an open-source Python library that provides the reference implementation of the Jupyter Notebook format (versions 1 through 4), JSON Schema files for validation, and APIs for reading, writing, converting, and signing notebook documents.
File structure
• Top-level directories & files
– nbformat/ : the Python package subdivided into modules (reader, converter, validator, sign, JSON compatibility, versioned sub-packages v1–v4, corpus of test words)
– scripts/ : CLI helper script (jupyter-trust)
– docs/ : Sphinx documentation source (.rst) and build configs
– tests/ : unit- and integration tests organized by API and by version
– CI/CD configs (.github/workflows/*.yml), packaging (pyproject.toml, package.json), and root scripts (index.js)
• Patterns
– Layered architecture: public API → I/O modules (reader/writer) → versioned converters → validators → signers
– Pluggable validator: choice of fastjsonschema or jsonschema via NBFORMAT_VALIDATOR env var
– Test harness driving each version’s modules and schema conformance