From a470656e9953af7c375743c77ae94dae542969f0 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Mon, 22 Sep 2025 22:27:51 +0200 Subject: [PATCH 1/2] Document command arguments --- README.md | 13 +++++++++++++ src/plugin.ts | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f2a673..3af4e52 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,19 @@ app.commands.execute('jupyterlab-cell-diff:show-codemirror', { }); ``` +#### Command Arguments + +The `jupyterlab-cell-diff:show-codemirror` command accepts the following arguments: + +| Argument | Type | Required | Description | +|----------|------|----------|-------------| +| `cellId` | `string` | No | ID of the cell to show diff for. If not provided, uses the active cell | +| `originalSource` | `string` | Yes | Original source code to compare against | +| `newSource` | `string` | Yes | New source code to compare with | +| `showActionButtons` | `boolean` | No | Whether to show action buttons in the diff widget (default: `true`) | +| `notebookPath` | `string` | No | Path to the notebook containing the cell. If not provided, uses the current notebook | +| `openDiff` | `boolean` | No | Whether to open the diff widget automatically (default: `true`) | + ## Uninstall To remove the extension, execute: diff --git a/src/plugin.ts b/src/plugin.ts index c0c9eb4..ed48514 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -105,7 +105,8 @@ const codeMirrorPlugin: JupyterFrontEndPlugin = { 'Whether to open the diff widget automatically' ) } - } + }, + required: ['originalSource', 'newSource'] } }, execute: async (args: any = {}) => { @@ -118,6 +119,13 @@ const codeMirrorPlugin: JupyterFrontEndPlugin = { openDiff = true } = args; + if (!originalSource || !newSource) { + console.error( + trans.__('Missing required arguments: originalSource and newSource') + ); + return; + } + const currentNotebook = findNotebook(notebookTracker, notebookPath); if (!currentNotebook) { return; From 1021f69e5e7fcc344231cc39a753b3a3d4f69b77 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Mon, 22 Sep 2025 22:31:51 +0200 Subject: [PATCH 2/2] lint --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3af4e52..1704e48 100644 --- a/README.md +++ b/README.md @@ -52,14 +52,14 @@ app.commands.execute('jupyterlab-cell-diff:show-codemirror', { The `jupyterlab-cell-diff:show-codemirror` command accepts the following arguments: -| Argument | Type | Required | Description | -|----------|------|----------|-------------| -| `cellId` | `string` | No | ID of the cell to show diff for. If not provided, uses the active cell | -| `originalSource` | `string` | Yes | Original source code to compare against | -| `newSource` | `string` | Yes | New source code to compare with | -| `showActionButtons` | `boolean` | No | Whether to show action buttons in the diff widget (default: `true`) | -| `notebookPath` | `string` | No | Path to the notebook containing the cell. If not provided, uses the current notebook | -| `openDiff` | `boolean` | No | Whether to open the diff widget automatically (default: `true`) | +| Argument | Type | Required | Description | +| ------------------- | --------- | -------- | ------------------------------------------------------------------------------------ | +| `cellId` | `string` | No | ID of the cell to show diff for. If not provided, uses the active cell | +| `originalSource` | `string` | Yes | Original source code to compare against | +| `newSource` | `string` | Yes | New source code to compare with | +| `showActionButtons` | `boolean` | No | Whether to show action buttons in the diff widget (default: `true`) | +| `notebookPath` | `string` | No | Path to the notebook containing the cell. If not provided, uses the current notebook | +| `openDiff` | `boolean` | No | Whether to open the diff widget automatically (default: `true`) | ## Uninstall