Commit 3ddfada
feat: Implement dependency parsing for Python and JavaScript projects
## Dependency Extraction
Implemented comprehensive dependency parsing to extract project dependencies from package files and include them in the documentation context.
### Files Modified
**memdocs/extract.py** (+135 lines):
- Added `_parse_dependencies()` - Main dispatcher method
- Added `_parse_requirements_txt()` - Parse Python requirements.txt
- Added `_parse_pyproject_toml()` - Parse pyproject.toml (PEP 621 & Poetry)
- Added `_parse_package_json()` - Parse package.json dependencies
- Updated `extract_file_context()` to call dependency parsing
- Removed TODO comment at line 168
**tests/unit/test_extract.py** (+256 lines):
- 11 comprehensive test methods
- Tests all file formats and edge cases
- 100% coverage of new parsing code
### Supported Formats
**Python - requirements.txt**:
```
anthropic>=0.34.0
click>=8.1.0
# Comments ignored
pydantic>=2.0.0
```
**Python - pyproject.toml (PEP 621)**:
```toml
[project]
dependencies = [
"anthropic>=0.34.0",
"click>=8.1.0",
]
```
**Python - pyproject.toml (Poetry)**:
```toml
[tool.poetry.dependencies]
python = "^3.10"
anthropic = ">=0.34.0"
```
**JavaScript/TypeScript - package.json**:
```json
{
"dependencies": {"react": "^18.0.0"},
"devDependencies": {"typescript": "^5.0.0"}
}
```
### Features
- **Multi-format support**: PEP 621, Poetry, npm
- **Error handling**: Gracefully handles missing files, invalid JSON/TOML
- **Deduplication**: Removes duplicates from multiple sources
- **Language-aware**: Only parses relevant files per language
- **Version preservation**: Maintains version specifiers (>=, ==, ^, ~)
### Test Results
✅ 21 tests passing in test_extract.py
✅ Extract module coverage: 83% (+7%)
✅ All existing tests continue to pass
### Example Usage
```python
extractor = Extractor(repo_path=Path('.'))
context = extractor.extract_file_context(Path('src/main.py'))
# context.dependencies = ['anthropic>=0.34.0', 'click>=8.1.0', ...]
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 447f65f commit 3ddfada
2 files changed
+400
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
175 | 180 | | |
176 | 181 | | |
177 | 182 | | |
178 | 183 | | |
179 | 184 | | |
180 | 185 | | |
181 | | - | |
| 186 | + | |
182 | 187 | | |
183 | 188 | | |
184 | 189 | | |
| |||
436 | 441 | | |
437 | 442 | | |
438 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
0 commit comments