Skip to content

Commit ffd1334

Browse files
committed
docs: consolidate tools documentation and remove duplicates
Deleted duplicates: - tools/mindmaps_config.toml (identical to generate_mindmaps.toml) - tools/run_tests.py (run_format_tests.py has better arg handling) - tools/MIGRATION_GUIDE.md (covered in docs/ARCHITECTURE_MIGRATION.md) - docs/FORMAT_CHECKING.md (merged into docs/TOOLS.md) Reorganized: - docs/TOOLS.md now includes format checking guide - tools/README.md simplified to quick start with links to docs - Updated mkdocs.yml and MKDOCS_CONTENT_GUIDE.md
1 parent d674641 commit ffd1334

File tree

7 files changed

+283
-627
lines changed

7 files changed

+283
-627
lines changed

docs/MKDOCS_CONTENT_GUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The following directories and files **do NOT** appear in the MkDocs website and
6060
| Directory/File | Description | GitHub Link Format |
6161
|:---------------|:------------|:-------------------|
6262
| `tools/*.py` | Tool scripts (code only) | `https://github.com/lufftw/neetcode/blob/main/tools/...` |
63-
| `tools/README.md` | Original tools readme | ✅ Documented at [docs/TOOLS.md](https://lufftw.github.io/neetcode/TOOLS/) |
63+
| `tools/README.md` | Quick start guide | References [docs/TOOLS.md](https://lufftw.github.io/neetcode/TOOLS/) |
6464
| `ontology/` | Algorithm ontology data (TOML) | `https://github.com/lufftw/neetcode/blob/main/ontology/...` |
6565
| `meta/` | Problem and pattern metadata | `https://github.com/lufftw/neetcode/blob/main/meta/...` |
6666
| `roadmaps/` | Learning path definitions | `https://github.com/lufftw/neetcode/blob/main/roadmaps/...` |

docs/TOOLS.md

Lines changed: 261 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,126 @@
11
# Solution Tools
22

3-
Tools for checking and validating solution files.
3+
Tools for checking and validating solution files against the Pure Polymorphic Architecture standards.
44

5-
## Tools
5+
## Quick Start
66

7-
### `check_solutions.py`
7+
```bash
8+
# Run format checker (quick check)
9+
python tools/check_solutions.py
810

9-
Main checker for solution file compliance with Pure Polymorphic Architecture.
11+
# Run format unit tests
12+
python tools/run_format_tests.py
13+
14+
# Run full format check (checker + tests)
15+
tools\run_format_tests.bat # Windows
16+
tools/run_format_tests.sh # Linux/Mac
17+
18+
# Run ALL tests (format + component + correctness)
19+
.dev\run_all_tests.bat # Windows
20+
.dev/run_all_tests.sh # Linux/Mac
21+
```
1022

11-
**Checks:**
23+
---
1224

13-
1. SOLUTIONS dictionary exists
14-
2. SOLUTIONS contains 'class' field
15-
3. No wrapper functions (solve_*)
16-
4. solve() uses get_solver()
17-
5. Imports _runner.get_solver
18-
6. Solution comment format: "Solution 1:" not "Solution:" or "Solution -"
19-
7. Solution classes have Time and Space complexity comments
25+
## Tools Overview
26+
27+
### `check_solutions.py`
28+
29+
Command-line tool to check all solution files for compliance. Provides a detailed report of issues grouped by type.
2030

2131
**Usage:**
2232

2333
```bash
24-
python tools/check_solutions.py
34+
python tools/check_solutions.py # Standard check
35+
python tools/check_solutions.py --verbose # Show suggestions
2536
```
2637

38+
**Checks performed:**
39+
40+
1. **Architecture Compliance**
41+
- `SOLUTIONS` dictionary exists
42+
- `SOLUTIONS` contains `'class'` field
43+
- No wrapper functions (`solve_*`)
44+
- `solve()` uses `get_solver()`
45+
- Proper import: `from _runner import get_solver`
46+
47+
2. **Code Format**
48+
- Solution comments use "Solution 1:" format (not "Solution:" or "Solution -")
49+
- Solution comments are BEFORE class definitions (not inside)
50+
51+
3. **Complexity Comments**
52+
- Each solution has `# Time: O(...)` comment
53+
- Each solution has `# Space: O(...)` comment
54+
55+
**Output:**
56+
57+
- Summary statistics (total files, OK count, error count, warning count)
58+
- Grouped issues by type (Architecture, Format, Complexity)
59+
- Detailed error messages with file names and line numbers
60+
- Suggestions for fixes (with `--verbose`)
61+
2762
### `run_format_tests.py`
2863

29-
Standalone script to run format checking unit tests.
64+
Standalone script to run unit tests for format checking.
3065

3166
**Usage:**
3267

3368
```bash
34-
# Direct execution
35-
python tools/run_format_tests.py
69+
python tools/run_format_tests.py # Standard
70+
python tools/run_format_tests.py --verbose # Verbose output
71+
python tools/run_format_tests.py --quiet # Quiet mode
72+
```
3673

37-
# With verbose output
38-
python tools/run_format_tests.py --verbose
74+
### `run_format_tests.bat` / `run_format_tests.sh`
3975

40-
# Using shell scripts (recommended)
76+
Shell scripts that run both the format checker and unit tests.
77+
78+
```bash
4179
# Windows
4280
tools\run_format_tests.bat
4381

4482
# Linux/Mac
4583
tools/run_format_tests.sh
4684
```
4785

48-
## Tests
86+
---
87+
88+
## Unit Tests
89+
90+
### `tools/tests/test_solution_format.py`
91+
92+
Comprehensive unit tests for solution file format validation. Tests are separated from:
93+
94+
- Component tests (`.dev/tests/`) - Runner module functionality
95+
- Solution correctness tests (`.dev/tests_solutions/`) - Test case validation
4996

50-
### `tests/test_solution_format.py`
97+
**Test Methods:**
5198

52-
Unit tests for solution file format:
99+
| Test | Description |
100+
|------|-------------|
101+
| `test_solution_comment_format` | Validates "Solution 1:" format |
102+
| `test_complexity_comments` | Checks Time/Space complexity presence |
103+
| `test_solutions_dictionary_exists` | Validates SOLUTIONS dictionary exists |
104+
| `test_solutions_dictionary_structure` | Validates SOLUTIONS has 'class' field |
105+
| `test_no_wrapper_functions` | Ensures no `solve_*` wrapper functions |
106+
| `test_uses_get_solver` | Verifies `get_solver()` usage |
107+
| `test_solution_comment_before_class` | Checks comment placement |
108+
| `test_all_solution_classes_have_comments` | All Solution* classes have comments |
53109

54-
- `test_solution_comment_format()` - Validates Solution comment format
55-
- `test_complexity_comments()` - Checks Time/Space complexity presence
56-
- `test_solutions_dictionary_structure()` - Validates SOLUTIONS structure
57-
- `test_no_wrapper_functions()` - Ensures no wrapper functions exist
58-
- `test_uses_get_solver()` - Verifies get_solver() usage
110+
**Running Tests:**
111+
112+
```bash
113+
# Via pytest
114+
pytest tools/tests/test_solution_format.py -v
115+
116+
# Via unittest
117+
python -m unittest tools.tests.test_solution_format
118+
119+
# Via standalone script
120+
python tools/run_format_tests.py
121+
```
122+
123+
---
59124

60125
## Architecture Requirements
61126

@@ -66,10 +131,16 @@ All solution files must follow the Pure Polymorphic Architecture:
66131
```python
67132
SOLUTIONS = {
68133
"default": {
69-
"class": "SolutionTwoPointers",
70-
"method": "removeElement",
134+
"class": "SolutionTwoPointers", # Required
135+
"method": "methodName",
71136
"complexity": "O(n) time, O(1) space",
72-
"description": "Reader/writer pointer pattern",
137+
"description": "Solution description",
138+
},
139+
"alternative": {
140+
"class": "SolutionHashMap",
141+
"method": "methodName",
142+
"complexity": "O(n) time, O(n) space",
143+
"description": "Alternative approach",
73144
},
74145
}
75146
```
@@ -86,20 +157,177 @@ class SolutionTwoPointers:
86157

87158
```python
88159
# ============================================
89-
# Solution 1: Description
160+
# Solution 1: Two Pointers
90161
# Time: O(n), Space: O(1)
91-
# - Additional details
162+
# - Explanation of algorithm
163+
# - Key insights
92164
# ============================================
165+
class SolutionTwoPointers:
166+
...
93167
```
94168

169+
**Valid formats:**
170+
171+
- `# Solution 1: Two Pointers`
172+
- `# Solution 2: Hash Map Approach`
173+
174+
**Invalid formats:**
175+
176+
- `# Solution: Two Pointers` (missing number)
177+
- `# Solution - Two Pointers` (wrong separator)
178+
- Inside class definition (wrong placement)
179+
95180
### 4. solve() Function
96181

97182
```python
183+
from _runner import get_solver
184+
98185
def solve():
99186
solver = get_solver(SOLUTIONS)
100-
result = solver.methodName(args)
187+
result = solver.methodName(...)
188+
return result
189+
```
190+
191+
---
192+
193+
## Test Structure
194+
195+
The project has three separate test categories:
196+
197+
```
198+
neetcode/
199+
├── .dev/
200+
│ ├── tests/ # Component tests (runner modules)
201+
│ │ ├── test_integration.py
202+
│ │ ├── test_test_runner.py
203+
│ │ └── ...
204+
│ ├── tests_solutions/ # Solution correctness tests
205+
│ │ └── test_all_solutions.py
206+
│ ├── run_tests.bat/sh # Run component tests only
207+
│ ├── run_tests_solutions.bat/sh # Run correctness tests only
208+
│ └── run_all_tests.bat/sh # Run ALL tests
209+
210+
└── tools/
211+
├── tests/ # Format compliance tests
212+
│ └── test_solution_format.py
213+
├── check_solutions.py # Format checker tool
214+
├── run_format_tests.py # Format test runner
215+
└── run_format_tests.bat/sh # Format test scripts
216+
```
217+
218+
---
219+
220+
## Running All Tests
221+
222+
To run the complete test suite:
223+
224+
```bash
225+
# Windows
226+
.dev\run_all_tests.bat
227+
228+
# Linux/Mac
229+
.dev/run_all_tests.sh
230+
```
231+
232+
This runs:
233+
234+
1. **Solution Format Tests** - Architecture compliance
235+
2. **Component Tests** - Runner module functionality
236+
3. **Solution Correctness Tests** - Test case validation
237+
238+
---
239+
240+
## CI/CD Integration
241+
242+
Example GitHub Actions workflow:
243+
244+
```yaml
245+
name: Tests
246+
on: [push, pull_request]
247+
248+
jobs:
249+
test:
250+
runs-on: ubuntu-latest
251+
steps:
252+
- uses: actions/checkout@v3
253+
- uses: actions/setup-python@v4
254+
with:
255+
python-version: '3.11'
256+
- run: pip install pytest
257+
- run: python tools/check_solutions.py
258+
- run: pytest tools/tests/ -v
259+
- run: pytest .dev/tests/ -v
260+
- run: pytest .dev/tests_solutions/ -v
261+
```
262+
263+
**Exit Codes:**
264+
265+
| Code | Meaning |
266+
|------|---------|
267+
| `0` | All checks/tests passed |
268+
| `1` | Errors found / Tests failed |
269+
270+
---
271+
272+
## Common Issues and Fixes
273+
274+
### Missing Solution Comment
275+
276+
**Issue:**
277+
278+
```
279+
0001_two_sum.py:30 - Class Solution missing Solution comment before definition
280+
```
281+
282+
**Fix:** Add comment before class:
283+
284+
```python
285+
# ============================================
286+
# Solution 1: Hash Map
287+
# Time: O(n), Space: O(n)
288+
# ============================================
289+
class Solution:
290+
...
291+
```
292+
293+
### Wrong Comment Format
294+
295+
**Issue:**
296+
297+
```
298+
0001_two_sum.py:25 - Use 'Solution 1:' format (not 'Solution:')
299+
```
300+
301+
**Fix:** Change `# Solution:` to `# Solution 1:`
302+
303+
### Missing Complexity
304+
305+
**Issue:**
306+
307+
```
308+
0001_two_sum.py:25 - Missing Time and Space complexity
101309
```
102310

311+
**Fix:** Add complexity comments:
312+
313+
```python
314+
# Solution 1: Hash Map
315+
# Time: O(n)
316+
# Space: O(n)
317+
```
318+
319+
### Comment Inside Class
320+
321+
**Issue:**
322+
323+
```
324+
0001_two_sum.py:30 - Class Solution has Solution comment inside class
325+
```
326+
327+
**Fix:** Move comment from inside class to before class definition.
328+
329+
---
330+
103331
## Related Documentation
104332

105333
- [Solution Contract](SOLUTION_CONTRACT.md) - Full solution file specification
@@ -114,4 +342,3 @@ The following tools have been removed or consolidated:
114342
- `batch_migrate_remaining.py` - Migration completed, no longer needed
115343
- `check_migration.py` - Replaced by `check_solutions.py`
116344
- `check_solution_format.py` - Merged into `check_solutions.py`
117-

0 commit comments

Comments
 (0)