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

Function resolveCodeExample

scripts/docs_sync/main.ts:111–131  ·  view source on GitHub ↗
(file: string, anchor: string)

Source from the content-addressed store, hash-verified

109}
110
111async function resolveCodeExample(file: string, anchor: string): Promise<string[]> {
112 const output: string[] = [];
113 const lines = await readLines(file);
114 let row = 0;
115 while (row < lines.length) {
116 const line = lines[row++];
117 const match = /^(\s*)\/\/ <docs anchor="(.*)">/.exec(line);
118 if (match && match[2] == anchor) {
119 while (row < lines.length) {
120 const offset = match[1].length;
121 const line2 = lines[row++].slice(offset);
122 const match2 = /\/\/ <\/docs>/.exec(line2);
123 if (match2) {
124 break;
125 }
126 output.push(line2);
127 }
128 }
129 }
130 return output;
131}
132
133const LINE_WIDTH = 95;
134

Callers 1

resolveCommentFunction · 0.85

Calls 1

readLinesFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…