#!/usr/bin/env python3 """Render docs/FEATURE_MATRIX.md to docs/FEATURE_MATRIX.html. The markdown tables are the source of truth; this gives them a browsable view with color-coded status cells (green = full, amber = partial, red = missing). Run it whenever the matrix changes: python3 scripts/feature-matrix-html.py """ import html import os import re import sys ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def cell_class(c): t = c.strip() if '✅' in t: return 'ok' if '◐' in t: return 'part' if t.startswith('✗'): return 'no' if t in ('—', '— single framebuffer'): return 'na' return '' def inline(s): s = html.escape(s) s = re.sub(r'`([^`]+)`', r'\1', s) s = re.sub(r'\*\*([^*]+)\*\*', r'\1', s) return s def convert(src): out = [''' Kryon Feature Matrix '''] para = [] def flush(): if para: out.append('

' + ' '.join(inline(x) for x in para) + '

') para.clear() i = 0 while i < len(src): line = src[i] if line.startswith('|'): flush() rows = [] while i < len(src) and src[i].startswith('|'): cells = [c.strip() for c in src[i].strip().strip('|').split('|')] if not all(re.fullmatch(r':?-{2,}:?', c) for c in cells): rows.append(cells) i += 1 out.append('') out.append('' + ''.join(f'' for c in rows[0]) + '') for r in rows[1:]: out.append('' + ''.join( f'' for c in r) + '') out.append('
{inline(c)}
{inline(c)}
') continue if line.startswith('```'): flush() i += 1 buf = [] while i < len(src) and not src[i].startswith('```'): buf.append(src[i]) i += 1 i += 1 out.append('
' + html.escape('\n'.join(buf)) + '
') continue if line.startswith('#'): flush() n = len(line) - len(line.lstrip('#')) out.append(f'{inline(line.lstrip("# ").strip())}') elif line.startswith('- '): flush() out.append('') continue elif line.strip(): para.append(line.strip()) else: flush() i += 1 flush() out.append('') return '\n'.join(out) def main(): src_path = os.path.join(ROOT, 'docs', 'FEATURE_MATRIX.md') dst_path = os.path.join(ROOT, 'docs', 'FEATURE_MATRIX.html') with open(src_path) as f: src = f.read().splitlines() rendered = convert(src) with open(dst_path, 'w') as f: f.write(rendered) print(f'rendered {dst_path}: ' f'{rendered.count("")} tables, ' f'{rendered.count("")} rows') if __name__ == '__main__': sys.exit(main())