| 11 | const runner = "@effect/doctest/Runner" |
| 12 | |
| 13 | const collectorModule = ( |
| 14 | file: string, |
| 15 | snippets: ReadonlyArray<Source.Snippet>, |
| 16 | version?: string | undefined |
| 17 | ): string => { |
| 18 | const tests = snippets.map((snippet, index) => { |
| 19 | const id = JSON.stringify(Protocol.snippetId(file, index, version)) |
| 20 | const label = JSON.stringify(snippet.name ?? `line ${snippet.line}`) |
| 21 | return `test(${label}, () => import(${id}))` |
| 22 | }) |
| 23 | |
| 24 | return `import { test } from "@effect/doctest/Runtime"\n\n${tests.join("\n\n")}\n` |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Creates a Vite plugin that transforms marked documentation snippets into Vitest tests. |