MCPcopy Index your code
hub / github.com/QwikDev/qwik / createApiData

Function createApiData

scripts/api-docs.ts:76–198  ·  view source on GitHub ↗
(
  config: BuildConfig,
  docsApiJsonPath: string,
  apiOuputDir: string,
  subPkgName: string
)

Source from the content-addressed store, hash-verified

74}
75
76async function createApiData(
77 config: BuildConfig,
78 docsApiJsonPath: string,
79 apiOuputDir: string,
80 subPkgName: string
81) {
82 const apiExtractedJson = JSON.parse(readFileSync(docsApiJsonPath, 'utf-8'));
83
84 const apiData: ApiData = {
85 id: subPkgName.replace('@builder.io/', '').replace(/\//g, '-'),
86 package: subPkgName,
87 members: [],
88 };
89
90 function addMember(apiExtract: any, hierarchyStr: string) {
91 const apiName = apiExtract.name || '';
92 const apiKind = apiExtract.kind || '';
93 if (apiName.length === 0) {
94 return;
95 }
96
97 if (apiKind === 'PropertySignature') {
98 if (!apiName.includes(':')) {
99 // do not include PropertySignatures unless they are namespaced
100 // like q:slot or preventdefault:click
101 return;
102 }
103 }
104
105 const hierarchySplit = hierarchyStr.split('/').filter((m) => m.length > 0);
106 hierarchySplit.push(apiName);
107
108 const hierarchy = hierarchySplit.map((h) => {
109 return {
110 name: h,
111 id: getCanonical(hierarchySplit),
112 };
113 });
114
115 const id = getCanonical(hierarchySplit);
116
117 const mdFile = getMdFile(subPkgName, hierarchySplit);
118 const mdPath = join(apiOuputDir, mdFile);
119
120 const content: string[] = [];
121
122 if (existsSync(mdPath)) {
123 const mdSrcLines = readFileSync(mdPath, 'utf-8').split(/\r?\n/);
124
125 for (const line of mdSrcLines) {
126 if (line.startsWith('## ')) {
127 continue;
128 }
129 if (line.startsWith('[Home]')) {
130 continue;
131 }
132 if (line.startsWith('<!-- ')) {
133 continue;

Callers 1

Calls 8

addMembersFunction · 0.85
getMemberNameCountsFunction · 0.85
getMemberAnchorIdFunction · 0.85
replaceMemberLinksFunction · 0.85
joinFunction · 0.85
createApiJsonDataFunction · 0.85
createApiMarkdownFunction · 0.85
parseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…