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

Function createApiMarkdown

scripts/api-docs.ts:200–283  ·  view source on GitHub ↗
(a: ApiData)

Source from the content-addressed store, hash-verified

198}
199
200async function createApiMarkdown(a: ApiData) {
201 let md: string[] = [];
202
203 const memberNameCounts = getMemberNameCounts(a.members);
204
205 md.push(`---`);
206 md.push(`title: \\${a.package} API Reference`);
207 md.push(`---`);
208 md.push(``);
209 md.push(`# [API](/api) › ${a.package}`);
210 md.push(``);
211
212 for (const m of a.members) {
213 // const title = `${toSnakeCase(m.kind)} - ${m.name.replace(/"/g, '')}`;
214 const anchorId = m.anchorId ?? getMemberAnchorId(m, memberNameCounts);
215
216 md.push(`<h2 id="${anchorId}">${m.name}</h2>`);
217 md.push(``);
218
219 // sanitize / adjust output
220
221 // Process the content to escape { characters only outside code blocks
222 let processedContent = '';
223 let inCodeBlock = false;
224 let inInlineCode = false;
225
226 const lines = m.content.split('\n');
227
228 for (let i = 0; i < lines.length; i++) {
229 let line = lines[i]
230 .replace(/<!--(.|\s)*?-->/g, '')
231 // .replace(/<Slot\/>/g, ''
232 .replace(/\\#\\#\\# (\w+)/gm, '### $1')
233 .replace(/\\\[/gm, '[')
234 .replace(/\\\]/gm, ']');
235
236 // Check for triple backtick code blocks
237 if (line.trim().startsWith('```')) {
238 inCodeBlock = !inCodeBlock;
239 processedContent += line + '\n';
240 continue;
241 }
242
243 if (!inCodeBlock) {
244 // Process line character by character for inline code
245 let newLine = '';
246 for (let j = 0; j < line.length; j++) {
247 const char = line[j];
248
249 // Toggle inline code state when we see a backtick
250 if (char === '`') {
251 inInlineCode = !inInlineCode;
252 newLine += char;
253 continue;
254 }
255
256 // Escape { when not in any code context
257 if (char === '{' && !inInlineCode) {

Callers 1

createApiDataFunction · 0.85

Calls 4

getMemberNameCountsFunction · 0.85
getMemberAnchorIdFunction · 0.85
formatFunction · 0.85
joinMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…