MCPcopy
hub / github.com/QwikDev/qwik / resolveComment

Function resolveComment

scripts/docs_sync/main.ts:64–84  ·  view source on GitHub ↗
(dir: string, ref: string, section: string)

Source from the content-addressed store, hash-verified

62}
63
64async function resolveComment(dir: string, ref: string, section: string): Promise<string[]> {
65 const fileReadme = join(dir, ref);
66 const lines = await readFileSection(fileReadme, section);
67 let row = 0;
68 let output: string[] = [];
69 const dirReadme = dirname(fileReadme);
70 while (row < lines.length) {
71 let line = lines[row++];
72 const match = /<docs code="\.\/(.*)#(.*)"\/>/.exec(line);
73 if (match) {
74 output.push('```tsx');
75 (await resolveCodeExample(join(dirReadme, match[1]), match[2])).forEach((l) =>
76 output.push(l)
77 );
78 output.push('```');
79 } else {
80 output.push(line);
81 }
82 }
83 return output;
84}
85
86async function readFileSection(file: string, section: string) {
87 const lines = await readLines(file);

Callers 1

scanForDocDirectiveFunction · 0.85

Calls 4

joinFunction · 0.85
readFileSectionFunction · 0.85
dirnameFunction · 0.85
resolveCodeExampleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…