MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / docstringEnd

Function docstringEnd

graph-ui/src/browser-ai/code-facts.ts:67–75  ·  view source on GitHub ↗

Where a docstring after line `after` ends, or `after` without one.

(lines: readonly string[], after: number)

Source from the content-addressed store, hash-verified

65
66/** Where a docstring after line `after` ends, or `after` without one. */
67function docstringEnd(lines: readonly string[], after: number): number {
68 const at = lines.findIndex((line, index) => index > after && line.trim());
69 const match = at >= 0 ? /^[rubRUB]{0,2}("""|''')/.exec(lines[at].trim()) : null;
70 if (!match) return after;
71 const rest = lines[at].trim().slice(match[0].length);
72 if (rest.includes(match[1])) return at;
73 const close = lines.findIndex((line, index) => index > at && line.includes(match[1]));
74 return close >= 0 ? close : lines.length - 1;
75}
76
77function pythonFacts(lines: readonly string[], name?: string): CodeFacts | undefined {
78 const definition = new RegExp(`^\\s*(?:async\\s+)?(?:def|class)\\s+${name ? `${escape(name)}\\b` : '\\w'}`);

Callers 1

pythonFactsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected