|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +Verify all gems from keen_collections are in the docs |
| 4 | +""" |
| 5 | + |
| 6 | +import json |
| 7 | +from pathlib import Path |
| 8 | +import subprocess |
| 9 | + |
| 10 | +def get_gem_ids_from_collections(): |
| 11 | + """Get all gem IDs from the collection JSON files""" |
| 12 | + collections_dir = Path('/home/user/elohim/docs/keen_collections') |
| 13 | + all_gem_ids = set() |
| 14 | + |
| 15 | + for json_file in collections_dir.glob('*.json'): |
| 16 | + if json_file.name == '_summary.json': |
| 17 | + continue |
| 18 | + |
| 19 | + with open(json_file, 'r') as f: |
| 20 | + data = json.load(f) |
| 21 | + for gem in data.get('gems', []): |
| 22 | + all_gem_ids.add(gem['gemId']) |
| 23 | + |
| 24 | + return all_gem_ids |
| 25 | + |
| 26 | +def find_gem_in_docs(gem_id): |
| 27 | + """Search for a gem ID in the docs""" |
| 28 | + result = subprocess.run( |
| 29 | + ['grep', '-r', '--include=*.md', gem_id, '/home/user/elohim/docs'], |
| 30 | + capture_output=True, |
| 31 | + text=True |
| 32 | + ) |
| 33 | + return result.returncode == 0 |
| 34 | + |
| 35 | +def main(): |
| 36 | + collection_gem_ids = get_gem_ids_from_collections() |
| 37 | + print(f"Total gems in collections: {len(collection_gem_ids)}") |
| 38 | + |
| 39 | + missing = [] |
| 40 | + found = [] |
| 41 | + |
| 42 | + for gem_id in sorted(collection_gem_ids): |
| 43 | + if find_gem_in_docs(gem_id): |
| 44 | + found.append(gem_id) |
| 45 | + else: |
| 46 | + missing.append(gem_id) |
| 47 | + |
| 48 | + print(f"Found in docs: {len(found)}") |
| 49 | + print(f"Missing from docs: {len(missing)}") |
| 50 | + |
| 51 | + if missing: |
| 52 | + print("\nMissing gem IDs:") |
| 53 | + for gem_id in missing: |
| 54 | + print(f" - {gem_id}") |
| 55 | + return False |
| 56 | + else: |
| 57 | + print("\n✓ All gems from collections are present in docs!") |
| 58 | + return True |
| 59 | + |
| 60 | +if __name__ == '__main__': |
| 61 | + success = main() |
| 62 | + exit(0 if success else 1) |
0 commit comments