Docs · API reference · Verso.Diffing

NotebookDiffEngine Class#

Computes a cell-level structural diff between two notebook versions.

public static class NotebookDiffEngine

Inheritance System.Object → NotebookDiffEngine

Methods#

Compute(NotebookModel, NotebookModel, string) Method#

Compares baseline against current without a cell-type registry, so every cell's outputs take part in the comparison.

public static Verso.Abstractions.NotebookDiffResult Compute(Verso.Abstractions.NotebookModel baseline, Verso.Abstractions.NotebookModel current, string baselineLabel);

Parameters#

baseline NotebookModel

current NotebookModel

baselineLabel System.String

Returns#

NotebookDiffResult

Compute(NotebookModel, NotebookModel, string, IReadOnlyList<ICellType>) Method#

Compares baseline against current and returns the aligned cell entries, notebook-level metadata changes, and summary counts.

public static Verso.Abstractions.NotebookDiffResult Compute(Verso.Abstractions.NotebookModel baseline, Verso.Abstractions.NotebookModel current, string baselineLabel, System.Collections.Generic.IReadOnlyList<Verso.Abstractions.ICellType>? cellTypes);

Parameters#

baseline NotebookModel

current NotebookModel

baselineLabel System.String

cellTypes System.Collections.Generic.IReadOnlyList<ICellType>

Returns#

NotebookDiffResult

Remarks#

The modified timestamp and format version are intentionally excluded from the metadata comparison: both change on every save and would report noise rather than meaningful edits. Parameters, extension settings, and per-layout state are compared through a canonical JSON form (recursively key-sorted), so a baseline holding System.Text.Json.JsonElement values compares equal to a live model holding CLR values of the same shape. Reported values are truncated for display; callers must not parse them back.

Outputs are excluded for the same reason, for cell types in cellTypes that declare PersistsOutputs as false. Those outputs are derived from the source and never written to disk, but hosts render them when a notebook opens, so a baseline read from a file has none where the live notebook has one. Comparing them would report every such cell as modified on an untouched notebook. When no registry is supplied all outputs take part, which is the safe reading for a caller that cannot say which types are transient.