MCPcopy Create free account
hub / github.com/Snapchat/Valdi / extract_api

Function extract_api

tools/api_surface/extract_api.py:299–338  ·  view source on GitHub ↗

Extract the full API surface from Valdi source files.

(open_source_root: Path)

Source from the content-addressed store, hash-verified

297
298
299def extract_api(open_source_root: Path) -> dict:
300 """Extract the full API surface from Valdi source files."""
301 valdi_tsx = (
302 open_source_root
303 / "src"
304 / "valdi_modules"
305 / "src"
306 / "valdi"
307 / "valdi_tsx"
308 / "src"
309 )
310 valdi_core = (
311 open_source_root
312 / "src"
313 / "valdi_modules"
314 / "src"
315 / "valdi"
316 / "valdi_core"
317 / "src"
318 )
319
320 nte_path = valdi_tsx / "NativeTemplateElements.d.ts"
321 component_path = valdi_core / "Component.ts"
322
323 if not nte_path.exists():
324 print(f"ERROR: {nte_path} not found", file=sys.stderr)
325 sys.exit(1)
326 if not component_path.exists():
327 print(f"ERROR: {component_path} not found", file=sys.stderr)
328 sys.exit(1)
329
330 nte_text = _strip_comments(nte_path.read_text())
331 component_text = component_path.read_text()
332
333 return {
334 "interfaces": _parse_interfaces(nte_text),
335 "types": _parse_type_aliases(nte_text),
336 "enums": _parse_enums(nte_text),
337 "classes": _parse_class_methods(component_text),
338 }
339
340
341def main():

Callers 3

checkFunction · 0.90
updateFunction · 0.90
mainFunction · 0.85

Calls 8

printFunction · 0.85
_strip_commentsFunction · 0.85
_parse_interfacesFunction · 0.85
_parse_type_aliasesFunction · 0.85
_parse_enumsFunction · 0.85
_parse_class_methodsFunction · 0.85
existsMethod · 0.65
exitMethod · 0.65

Tested by

no test coverage detected