Extract the full API surface from Valdi source files.
(open_source_root: Path)
| 297 | |
| 298 | |
| 299 | def 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 | |
| 341 | def main(): |
no test coverage detected