MCPcopy
hub / github.com/npmx-dev/npmx.dev / flattenNamespaces

Function flattenNamespaces

server/utils/docs/processing.ts:18–41  ·  view source on GitHub ↗
(nodes: DenoDocNode[])

Source from the content-addressed store, hash-verified

16 * Also filters out import/reference nodes that aren't useful for docs.
17 */
18export function flattenNamespaces(nodes: DenoDocNode[]): DenoDocNode[] {
19 const result: DenoDocNode[] = []
20
21 for (const node of nodes) {
22 // Skip internal nodes
23 if (node.kind === 'import' || node.kind === 'reference') {
24 continue
25 }
26
27 result.push(node)
28
29 // Inline namespace members with qualified names
30 if (node.kind === 'namespace' && node.namespaceDef?.elements) {
31 for (const element of node.namespaceDef.elements) {
32 result.push({
33 ...element,
34 name: `${node.name}.${element.name}`,
35 })
36 }
37 }
38 }
39
40 return result
41}
42
43/**
44 * Build a lookup table mapping symbol names to their HTML anchor IDs.

Callers 1

generateDocsWithDenoFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected