MCPcopy Create free account
hub / github.com/Effect-TS/effect / buildJSDocApis

Function buildJSDocApis

packages/tools/jsdocs/src/Jsdocs.ts:2078–2198  ·  view source on GitHub ↗
(files: ReadonlyArray<JSDocModelFile>)

Source from the content-addressed store, hash-verified

2076}
2077
2078function buildJSDocApis(files: ReadonlyArray<JSDocModelFile>): ReadonlyArray<JSDocApi> {
2079 const apis: Array<JSDocApi> = []
2080 const addMembers = (
2081 file: JSDocModelFile,
2082 imports: ParsedJSDocImports,
2083 members: ReadonlyArray<ParsedMember>,
2084 parentApiName: string,
2085 namespacePath: ReadonlyArray<string>,
2086 memberPath: ReadonlyArray<string>,
2087 sourcePath: ReadonlyArray<string | number>
2088 ) => {
2089 members.forEach((member, index) => {
2090 const nextMemberPath = [...memberPath, member.name]
2091 const apiName = `${parentApiName}.${nextMemberPath.join(".")}`
2092 apis.push(makeApi({
2093 file,
2094 imports,
2095 kind: "member",
2096 bucket: null,
2097 apiName,
2098 localName: member.name,
2099 signature: member.signature,
2100 parentApiName,
2101 namespacePath,
2102 memberPath: nextMemberPath,
2103 sourcePath: [...sourcePath, "members", index],
2104 sourceRange: member.range,
2105 description: member.description,
2106 examples: member.examples,
2107 tags: member.tags
2108 }))
2109 addMembers(file, imports, member.members, parentApiName, namespacePath, nextMemberPath, [
2110 ...sourcePath,
2111 "members",
2112 index
2113 ])
2114 })
2115 }
2116 const addNamespaces = (
2117 file: JSDocModelFile,
2118 imports: ParsedJSDocImports,
2119 namespaces: ReadonlyArray<ParsedNamespace>,
2120 namespacePath: ReadonlyArray<string>,
2121 sourcePath: ReadonlyArray<string | number>
2122 ) => {
2123 namespaces.forEach((namespace, index) => {
2124 const nextNamespacePath = [...namespacePath, namespace.name]
2125 const namespaceApiName = nextNamespacePath.join(".")
2126 apis.push(makeApi({
2127 file,
2128 imports,
2129 kind: "namespace",
2130 bucket: null,
2131 apiName: namespaceApiName,
2132 localName: namespace.name,
2133 signature: namespace.signature,
2134 parentApiName: namespacePath.length === 0 ? null : namespacePath.join("."),
2135 namespacePath: nextNamespacePath,

Calls 7

makeApiFunction · 0.85
addMembersFunction · 0.85
addNamespacesFunction · 0.85
resolveJSDocApiSeeLinksFunction · 0.85
markFqnCollisionsFunction · 0.85
pushMethod · 0.80
forEachMethod · 0.65

Tested by

no test coverage detected