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

Function readFileSection

scripts/docs_sync/main.ts:86–109  ·  view source on GitHub ↗
(file: string, section: string)

Source from the content-addressed store, hash-verified

84}
85
86async function readFileSection(file: string, section: string) {
87 const lines = await readLines(file);
88 let sectionStart = '# `' + section + '`';
89 let row = 0;
90 let output: string[] = [];
91 let inSection = false;
92 while (row < lines.length) {
93 const line = lines[row++];
94 if (line === sectionStart) {
95 inSection = true;
96 } else if (line.startsWith('# ')) {
97 inSection = false;
98 } else if (inSection) {
99 output.push(line);
100 }
101 }
102 while (output.length && output[0] == '') {
103 output.shift();
104 }
105 while (output.length && output[output.length - 1] == '') {
106 output.pop();
107 }
108 return output;
109}
110
111async function resolveCodeExample(file: string, anchor: string): Promise<string[]> {
112 const output: string[] = [];

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…