yusyus
|
33d8500c44
|
feat(C2.5): Add inline comment extraction for Python/JS/C++
- Added comment extraction methods to code_analyzer.py
- Supports Python (# style), JavaScript (// and /* */), C++ (// and /* */)
- Extracts comment text, line numbers, and type (inline vs block)
- Skips Python shebang and encoding declarations
- Preserves TODO/FIXME/NOTE markers for developer notes
Implementation:
- _extract_python_comments(): Extract # comments with line tracking
- _extract_js_comments(): Extract // and /* */ comments
- _extract_cpp_comments(): Reuses JS logic (same syntax)
- Integrated into _analyze_python(), _analyze_javascript(), _analyze_cpp()
Output Format:
{
'classes': [...],
'functions': [...],
'comments': [
{'line': 5, 'text': 'TODO: Optimize', 'type': 'inline'},
{'line': 12, 'text': 'Block comment\nwith lines', 'type': 'block'}
]
}
Tests:
- Added 8 comprehensive tests to test_code_analyzer.py
- Total: 30 tests passing ✅
- Python: Comment extraction, line numbers, shebang skip
- JavaScript: Inline comments, block comments, mixed
- C++: Comment extraction (uses JS logic)
- TODO/FIXME detection test
Related Issues:
- Closes #67 (C2.5 Extract inline comments as notes)
- Part of C2 Local Codebase Scraping roadmap (TIER 3)
Files Modified:
- src/skill_seekers/cli/code_analyzer.py (+67 lines)
- tests/test_code_analyzer.py (+194 lines)
|
2026-01-01 23:02:34 +03:00 |
|
yusyus
|
f162727792
|
test: Add comprehensive tests for code_analyzer.py (22 tests, 90% coverage)
- Created tests/test_code_analyzer.py with 22 comprehensive tests
- Python parsing: 8 tests (signatures, type hints, defaults, async, classes, docstrings, decorators, error handling)
- JavaScript/TypeScript: 5 tests (functions, arrow functions, classes, type annotations, async)
- C++ parsing: 4 tests (function signatures, classes, pointers, defaults)
- Depth levels: 3 tests (surface, deep, unknown language)
- Integration: 2 tests (public interface, multiple items)
Test Coverage:
- All 22 tests passing ✅
- 90% code coverage (exceeds 80% target)
- Validates Python AST parsing (production-ready)
- Documents regex parser limitations for JS/C++ (return types not extracted)
Related Issues:
- Addresses testing requirements for #64 (C2.2 Docstring extraction)
- Addresses testing requirements for #65 (C2.3 Function signatures)
Part of TIER 2 implementation plan for C2 Local Codebase Scraping tasks.
|
2026-01-01 22:58:08 +03:00 |
|