MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / sectionFor

Function sectionFor

__tests__/adaptive-explore-sizing.test.ts:41–53  ·  view source on GitHub ↗

Return the ``**` `** ...`` section for a file basename, header through the * line before the next bold header (or end of output). Headers are bold labels, * not ATX headings (issue #778); file sections start with ``**` ``.

(text: string, basename: string)

Source from the content-addressed store, hash-verified

39 * line before the next bold header (or end of output). Headers are bold labels,
40 * not ATX headings (issue #778); file sections start with ``**` ``. */
41function sectionFor(text: string, basename: string): string {
42 const lines = text.split('\n');
43 const start = lines.findIndex((l) => l.startsWith('**`') && l.includes(basename));
44 if (start < 0) return '';
45 let end = lines.length;
46 for (let i = start + 1; i < lines.length; i++) {
47 if (lines[i].startsWith('**')) {
48 end = i;
49 break;
50 }
51 }
52 return lines.slice(start, end).join('\n');
53}
54
55describe('adaptive codegraph_explore sizing — sibling skeletonization', () => {
56 let testDir: string;

Callers 1

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected