Notebook format interfaces and utilities for working with Jupyter Notebook format specifications
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Core interfaces for notebook documents, metadata structures, and format specifications. These interfaces define the overall structure of Jupyter notebooks and their associated metadata.
The main interface representing a complete Jupyter notebook document.
/**
* The notebook content interface representing a complete Jupyter notebook
*/
interface INotebookContent extends PartialJSONObject {
/** Notebook-level metadata */
metadata: INotebookMetadata;
/** Minor version of the nbformat specification */
nbformat_minor: number;
/** Major version of the nbformat specification */
nbformat: number;
/** Array of cells in the notebook */
cells: ICell[];
}Usage Example:
import { INotebookContent } from "@jupyterlab/nbformat";
const notebook: INotebookContent = {
metadata: {
kernelspec: {
name: "python3",
display_name: "Python 3"
}
},
nbformat: 4,
nbformat_minor: 4,
cells: []
};Metadata structure containing notebook-level configuration and information.
/**
* The default metadata for the notebook
*/
interface INotebookMetadata extends PartialJSONObject {
/** Kernel specification metadata */
kernelspec?: IKernelspecMetadata;
/** Programming language information */
language_info?: ILanguageInfoMetadata;
/** Original nbformat version */
orig_nbformat?: number;
}Kernel specification information describing the computational backend.
/**
* The kernelspec metadata describing the computational kernel
*/
interface IKernelspecMetadata extends PartialJSONObject {
/** Internal name of the kernel */
name: string;
/** Human-readable display name */
display_name: string;
}Usage Example:
import { IKernelspecMetadata } from "@jupyterlab/nbformat";
const kernelspec: IKernelspecMetadata = {
name: "python3",
display_name: "Python 3"
};Programming language configuration and metadata.
/**
* The language info metadata describing programming language settings
*/
interface ILanguageInfoMetadata extends PartialJSONObject {
/** Programming language name */
name: string;
/** CodeMirror mode configuration */
codemirror_mode?: string | PartialJSONObject;
/** Default file extension for the language */
file_extension?: string;
/** MIME type for the language */
mimetype?: string;
/** Pygments lexer name for syntax highlighting */
pygments_lexer?: string;
}Usage Example:
import { ILanguageInfoMetadata } from "@jupyterlab/nbformat";
const languageInfo: ILanguageInfoMetadata = {
name: "python",
codemirror_mode: {
name: "ipython",
version: 3
},
file_extension: ".py",
mimetype: "text/x-python",
pygments_lexer: "ipython3"
};Constants defining the supported nbformat specification versions.
/**
* The earliest major version of the notebook format we support
*/
const MAJOR_VERSION: number;
/**
* The earliest minor version of the notebook format we support
*/
const MINOR_VERSION: number;Usage Example:
import { MAJOR_VERSION, MINOR_VERSION } from "@jupyterlab/nbformat";
console.log(`Supporting nbformat ${MAJOR_VERSION}.${MINOR_VERSION}+`);
// Check notebook compatibility
function isCompatible(notebook: INotebookContent): boolean {
return notebook.nbformat >= MAJOR_VERSION &&
notebook.nbformat_minor >= MINOR_VERSION;
}