MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / readCorpusDocs

Function readCorpusDocs

scripts/rubi/compile.ts:29–42  ·  view source on GitHub ↗
(corpusDir: string)

Source from the content-addressed store, hash-verified

27 * (`bundle-corpus.ts`); keeping it in one place prevents the two from drifting
28 * (a divergence would silently change rule precedence). */
29export function readCorpusDocs(corpusDir: string): RubiRuleDoc[] {
30 const docs: RubiRuleDoc[] = [];
31 (function walk(dir: string): void {
32 for (const e of fs
33 .readdirSync(dir, { withFileTypes: true })
34 .sort((a, b) => a.name.localeCompare(b.name))) {
35 const p = path.join(dir, e.name);
36 if (e.isDirectory()) walk(p);
37 else if (e.name.endsWith('.json'))
38 docs.push(JSON.parse(fs.readFileSync(p, 'utf8')) as RubiRuleDoc);
39 }
40 })(corpusDir);
41 return docs;
42}
43
44/** Load and compile all corpus files under a section directory, in order. */
45export function compileSection(

Callers 3

mainFunction · 0.90
bundle-corpus.tsFile · 0.90
compileSectionFunction · 0.85

Calls 2

parseMethod · 0.65
walkFunction · 0.50

Tested by

no test coverage detected