MCPcopy Index your code
hub / github.com/npmx-dev/npmx.dev / getDocNodes

Function getDocNodes

server/utils/docs/client.ts:28–54  ·  view source on GitHub ↗
(packageName: string, version: string)

Source from the content-addressed store, hash-verified

26 * Get documentation nodes for a package using @deno/doc WASM.
27 */
28export 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

Callers 1

generateDocsWithDenoFunction · 0.90

Calls 3

getTypesUrlFunction · 0.85
createLoaderFunction · 0.85
createResolverFunction · 0.85

Tested by

no test coverage detected