(packageName: string, version: string)
| 26 | * Get documentation nodes for a package using @deno/doc WASM. |
| 27 | */ |
| 28 | export async function getDocNodes(packageName: string, version: string): Promise<DenoDocResult> { |
| 29 | // Get types URL from esm.sh header |
| 30 | const typesUrl = await getTypesUrl(packageName, version) |
| 31 | |
| 32 | if (!typesUrl) { |
| 33 | return { version: 1, nodes: [] } |
| 34 | } |
| 35 | |
| 36 | // Generate docs using @deno/doc WASM |
| 37 | let result: Record<string, DocNode[]> |
| 38 | try { |
| 39 | result = await doc([typesUrl], { |
| 40 | load: createLoader(), |
| 41 | resolve: createResolver(), |
| 42 | }) |
| 43 | } catch { |
| 44 | return { version: 1, nodes: [] } |
| 45 | } |
| 46 | |
| 47 | // Collect all nodes from all specifiers |
| 48 | const allNodes: DenoDocNode[] = [] |
| 49 | for (const nodes of Object.values(result)) { |
| 50 | allNodes.push(...(nodes as DenoDocNode[])) |
| 51 | } |
| 52 | |
| 53 | return { version: 1, nodes: allNodes } |
| 54 | } |
| 55 | |
| 56 | // ============================================================================= |
| 57 | // Module Loading |
no test coverage detected