( filePath: string, content: string, framework: Framework, tags: string[] )
| 594 | }); |
| 595 | } |
| 596 | |
| 597 | /** |
| 598 | * Extract routes from a Python file using AST. |
| 599 | * Returns routes with confidence: "ast", or null if Python is unavailable. |
| 600 | */ |
| 601 | export async function extractPythonRoutesAST( |
| 602 | filePath: string, |
| 603 | content: string, |
| 604 | framework: Framework, |
| 605 | tags: string[] |
| 606 | ): Promise<RouteInfo[] | null> { |
| 607 | const result = await runPythonWithStdin(PYTHON_ROUTE_SCRIPT, content, filePath); |
| 608 | if (!result || !Array.isArray(result) || result.length === 0) return null; |
| 609 | |
| 610 | // Tag from the handler's own line span when the AST reports one (issue #52); |
| 611 | // routes without span info (urlpatterns entries) keep the caller's tags. |
| 612 | const lines = content.split("\n"); |
| 613 | return result.map((r: any) => ({ |
| 614 | method: r.method, |
| 615 | path: r.path, |
| 616 | file: filePath, |
| 617 | tags: |
no test coverage detected