1npm run test:anki
ā Expected: 52 tests passing
1npm run anki:styles:list
ā Expected: psychology.css (16 KB), devops.css (17 KB)
1conda activate ags-anki
2
3python3 << 'PYTHON'
4import json
5from pathlib import Path
6from scripts.anki.apkg_generator import APKGGenerator
7import tempfile, shutil
8
9# Load real psychology data
10with open("data/course/psychology-l2/01/01m/001/anki/01-counselling-skills.json") as f:
11 data = json.load(f)
12
13# Ensure course metadata exists
14if 'course' not in data['metadata']:
15 data['metadata']['course'] = 'psychology'
16
17# Generate APKG with styling
18with tempfile.TemporaryDirectory() as tmpdir:
19 gen = APKGGenerator(verbose=True)
20 apkg = gen.generate_from_data(data, tmpdir, data['metadata'].get('deck_name'))
21
22 # Copy to Desktop
23 shutil.copy(apkg, Path.home() / "Desktop" / "psychology-real-data.apkg")
24 print(f\nā
APKG copied to ~/Desktop/psychology-real-data.apkg")
25
26 print(f" Size: {apkg.stat().st_size / 1024:.1f} KB (includes psychology CSS)")
27PYTHON
ā Expected:
~/Desktop/psychology-real-data.apkg| Test | Command | Expected Result |
|---|---|---|
| Unit Tests | npm run test:anki | 52 passing ā |
| CSS Compilation | npm run anki:styles:compile | Generates .css files |
| CSS Files Exist | npm run anki:styles:list | 2 files, ~33 KB total |
| Psychology APKG | Generate from real data | ~76 KB, psychology CSS embedded |
| DevOps APKG | Change course to “devops” | ~72 KB, devops CSS embedded |
| Default APKG | Remove course metadata | ~56 KB, minimal CSS |
| File Size Comparison | Compare all 3 | Psychology/DevOps ~12-16 KB larger |
| Anki Import | Import .apkg file | Cards appear with styling |
| Visual Inspection | Look at cards | Colors, fonts match design |
| File | Purpose |
|---|---|
scripts/anki/styles/_variables.scss | 80+ design tokens (colors, spacing, etc.) |
scripts/anki/styles/_base-components.scss | 20+ reusable CSS classes |
scripts/anki/styles/courses/psychology.scss | Psychology-specific overrides |
scripts/anki/styles/courses/devops.scss | DevOps-specific overrides |
scripts/anki/styles/psychology.css | Compiled output (16 KB) |
scripts/anki/styles/devops.css | Compiled output (17 KB) |
scripts/anki/apkg_generator.py | Modified to load and inject CSS |
tests/anki/test_css_integration.py | Integration tests for CSS |
TESTING_GUIDE.md | Complete testing documentation |
TESTING_VERIFICATION.md | Advanced verification methods |
| SCSS_IMPLEMENTATION_SUMMARY.md | Architecture and design reference |
1
2ls -lh ~/Desktop/*.apkg
3# Psychology: 68-76 KB
4# DevOps: 72 KB
5# Default: 56 KB
6# Difference = CSS embedded ā
1cd ~/Desktop
2unzip -l psychology-real-data.apkg
3# Should show: collection.anki2, media
1cd ~/Desktop
2unzip psychology-real-data.apkg collection.anki2
3
4# Query CSS size
5sqlite3 collection.anki2 "SELECT id, name, LENGTH(css) as css_bytes FROM models;"
6
7
8# View CSS content
9sqlite3 collection.anki2 "SELECT SUBSTR(css, 1, 500) FROM models WHERE id = 1;"
1
2npm run anki:styles:compile
3npm run anki:styles:list # Verify files exist
"course": "psychology"npm run anki:styles:list1# Make sure metadata includes course:
2data['metadata'] = {
3 "course": "psychology", # ā THIS IS REQUIRED
4 "deck_name": "...",
5 "unit": "...",
6 "module": "..."
7}
1# Styling
2npm run anki:styles:compile # Compile all SCSS ā CSS
3npm run anki:styles:compile:psychology # Psychology only
4npm run anki:styles:compile:devops # DevOps only
5npm run anki:styles:watch # Watch mode (dev)
6npm run anki:styles:list # List compiled CSS
7
8# Testing
9npm run test:anki # Run all Anki tests
10npm run test:anki:verbose # Detailed output
11npm run test:anki:coverage # Coverage report
12
13# APKG Generation
14npm run anki:rebuild # Rebuild all APKGs
15npm run anki:rebuild:verbose # With details
16npm run anki:rebuild:unit # Unit APKGs only
npm run test:anki ā 52/52npm run anki:styles:compile ā No errorsnpm run anki:styles:list ā psychology.css, devops.cssStatus: ā Production Ready
All systems tested and operational. Ready for visual testing and real-world use!