Skip to content

Commit 11005a4

Browse files
claude: wip jupyter discovery port 6/n
1 parent 603c883 commit 11005a4

5 files changed

Lines changed: 16 additions & 18 deletions

File tree

packages/quarto-types/src/quarto-api.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import type {
1717
} from './jupyter-types.ts';
1818
import { PandocIncludes } from './execution-engine.ts';
1919
import { Format } from './metadata-types.ts';
20+
import { EngineProjectContext } from './project-context.ts';
2021

2122
/**
2223
* Process execution result
@@ -231,19 +232,15 @@ export interface QuartoAPI {
231232
* Convert Quarto markdown to Jupyter notebook
232233
*
233234
* @param markdown - Markdown content with YAML frontmatter
234-
* @param kernelspec - Jupyter kernelspec for the notebook
235-
* @param title - Optional title for the notebook
236-
* @param format - Optional format information
237-
* @param options - Optional conversion options
238-
* @returns Jupyter notebook generated from markdown
235+
* @param includeIds - Whether to include cell IDs
236+
* @param project - Optional project context for config merging
237+
* @returns Promise resolving to Jupyter notebook generated from markdown
239238
*/
240239
quartoMdToJupyter: (
241240
markdown: string,
242-
kernelspec: JupyterKernelspec,
243-
title?: string,
244-
format?: Format,
245-
options?: QuartoMdToJupyterOptions
246-
) => JupyterNotebook;
241+
includeIds: boolean,
242+
project?: EngineProjectContext
243+
) => Promise<JupyterNotebook>;
247244

248245
// 3. Notebook Processing & Assets
249246

src/core/jupyter/jupyter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ import {
153153
removeIfEmptyDir,
154154
} from "../path.ts";
155155
import { convertToHtmlSpans, hasAnsiEscapeCodes } from "../ansi-colors.ts";
156-
import { kProjectType, ProjectContext } from "../../project/types.ts";
156+
import { kProjectType, EngineProjectContext } from "../../project/types.ts";
157157
import { mergeConfigs } from "../config.ts";
158158
import { encodeBase64 } from "encoding/base64";
159159
import {
@@ -290,7 +290,7 @@ const ticksForCode = (code: string[]) => {
290290
export async function quartoMdToJupyter(
291291
markdown: string,
292292
includeIds: boolean,
293-
project?: ProjectContext,
293+
project?: EngineProjectContext,
294294
): Promise<JupyterNotebook> {
295295
const [kernelspec, metadata] = await jupyterKernelspecFromMarkdown(
296296
markdown,
@@ -500,7 +500,7 @@ export async function quartoMdToJupyter(
500500

501501
export async function jupyterKernelspecFromMarkdown(
502502
markdown: string,
503-
project?: ProjectContext,
503+
project?: EngineProjectContext,
504504
): Promise<[JupyterKernelspec, Metadata]> {
505505
const config = project?.config;
506506
const yaml = config

src/core/quarto-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { MappedString } from "./lib/text-types.ts";
55
import { Format, Metadata, FormatPandoc } from "../config/types.ts";
66
import { PartitionedMarkdown } from "./pandoc/types.ts";
7-
import type { ProjectContext } from "../project/types.ts";
7+
import type { EngineProjectContext } from "../project/types.ts";
88
import type {
99
JupyterNotebook,
1010
JupyterToMarkdownOptions,
@@ -144,7 +144,7 @@ export interface QuartoAPI {
144144
isJupyterNotebook: (file: string) => boolean;
145145
isPercentScript: (file: string, extensions?: string[]) => boolean;
146146
notebookExtensions: string[];
147-
kernelspecFromMarkdown: (markdown: string, project?: ProjectContext) => Promise<[JupyterKernelspec, Metadata]>;
147+
kernelspecFromMarkdown: (markdown: string, project?: EngineProjectContext) => Promise<[JupyterKernelspec, Metadata]>;
148148
fromJSON: (nbJson: string) => JupyterNotebook;
149149

150150
// 2. Notebook Conversion
@@ -155,7 +155,7 @@ export interface QuartoAPI {
155155
markdownFromNotebookFile: (file: string, format?: Format) => Promise<string>;
156156
markdownFromNotebookJSON: (nb: JupyterNotebook) => string;
157157
percentScriptToMarkdown: (file: string) => string;
158-
quartoMdToJupyter: (markdown: string, includeIds: boolean, project?: ProjectContext) => Promise<JupyterNotebook>;
158+
quartoMdToJupyter: (markdown: string, includeIds: boolean, project?: EngineProjectContext) => Promise<JupyterNotebook>;
159159

160160
// 3. Notebook Processing & Assets
161161
notebookFiltered: (input: string, filters: string[]) => Promise<string>;

src/execute/jupyter/jupyter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ interface JupyterTargetData {
7070
import { quartoAPI as quarto } from "../../core/quarto-api.ts";
7171
import { postProcessRestorePreservedHtml } from "../engine-shared.ts";
7272
import { MappedString } from "../../core/mapped-text.ts";
73-
import { ProjectContext } from "../../project/types.ts";
7473
import { isQmdFile } from "../qmd.ts";
7574
import { kJupyterPercentScriptExtensions } from "./percent.ts";
7675
import {
@@ -670,7 +669,7 @@ function fixupShinyliveCodeCells(nb: JupyterNotebook) {
670669

671670
async function createNotebookforTarget(
672671
target: ExecutionTarget,
673-
project?: ProjectContext,
672+
project?: EngineProjectContext,
674673
) {
675674
const nb = await quarto.jupyter.quartoMdToJupyter(target.markdown.value, true, project);
676675
Deno.writeTextFileSync(target.input, JSON.stringify(nb, null, 2));

src/project/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,14 @@ export interface EngineProjectContext {
168168
/**
169169
* Config object containing project configuration
170170
* Used primarily for config?.engines access
171+
* Can contain arbitrary configuration properties
171172
*/
172173
config?: {
173174
engines?: string[];
174175
project?: {
175176
[kProjectOutputDir]?: string;
176177
};
178+
[key: string]: unknown;
177179
};
178180

179181
/**

0 commit comments

Comments
 (0)