secubox-openwrt/secubox-tools/sync_module_versions.py
CyberMind-FR ef936f1295 docs: Add GitHub Pages documentation site structure
Created comprehensive documentation site using MkDocs Material theme
for GitHub Pages deployment. Moved version sync scripts to secubox-tools.

## Documentation Site (18 new files)

Created docs/ directory with complete documentation:

**Main Pages:**
- index.md - Home page with navigation cards and module overview
- quick-start.md - Quick start guide
- documentation-index.md - Documentation index

**Development Guides:**
- development-guidelines.md - Complete development reference (1857 lines)
- code-templates.md - Working examples and patterns (1405 lines)
- module-implementation-guide.md - Step-by-step workflow (901 lines)

**Reference Documentation:**
- claude.md - Build system and RPCD architecture (553 lines)
- validation-guide.md - Validation workflows (518 lines)
- permissions-guide.md - Permission guidelines (248 lines)
- luci-development-reference.md - LuCI development (1196 lines)

**Module Information:**
- module-status.md - 15 module status (896 lines)
- feature-regeneration-prompts.md - AI prompts (2084 lines)
- todo-analyse.md - Roadmap and tasks (1080 lines)

**Archive (4 files):**
- archive/index.md - Archive index
- archive/build-issues.md - Build troubleshooting
- archive/completion-report.md - Project milestones
- archive/module-enable-disable-design.md - Feature design

**Styling:**
- stylesheets/extra.css - SecuBox custom CSS

## Scripts Reorganization (2 files moved)

Moved version sync utilities to secubox-tools:
- scripts/sync_module_versions.py → secubox-tools/sync_module_versions.py
- scripts/sync_module_versions.sh → secubox-tools/sync_module_versions.sh

## Site Features

- Material theme with dark/light mode
- Responsive design with navigation tabs
- Live search and syntax highlighting
- Custom SecuBox branding (indigo/violet gradients)
- 12,780+ lines of comprehensive documentation

Summary:
- 21 files changed (+12,780 lines)
- 18 new documentation pages
- 2 scripts relocated
- Ready for GitHub Pages deployment

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-28 21:57:29 +01:00

69 lines
2.0 KiB
Python
Executable File

#!/usr/bin/env python3
"""Synchronize module versions and website progress bars."""
from __future__ import annotations
import re
import sys
from pathlib import Path
import difflib
import subprocess
RE_WEBSITE = re.compile(
r'(<div class="module-progress-fill" style="width:)([0-9.]+)(%;"></div>\s*</div>\s*<div class="module-progress-label">v)'
r'([0-9]+\.[0-9]+\.[0-9]+)(?:\s*·\s*)([0-9.]+)(\s*/ 1.00</div>)'
)
def version_ratio(ver: str) -> float:
major, minor, patch = map(int, ver.split('.'))
return major + minor / 10 + patch / 100
def update_website(html: Path) -> bool:
text = html.read_text()
def repl(match: re.Match) -> str:
ver = match.group(4)
ratio = version_ratio(ver)
width = f"{ratio * 100:.0f}".rstrip('0').rstrip('.')
label = f"{ratio:.2f}".rstrip('0').rstrip('.')
return f"{match.group(1)}{width}{match.group(3)}{ver} · {label}{match.group(6)}"
new_text, count = RE_WEBSITE.subn(repl, text)
if count:
if new_text == text:
return False
diff = difflib.unified_diff(
text.splitlines(keepends=True),
new_text.splitlines(keepends=True),
fromfile=str(html),
tofile=str(html)
)
diff_text = ''.join(diff)
if not diff_text:
return False
subprocess.run(['patch', str(html)], input=diff_text.encode(), check=True)
return True
return False
def main() -> int:
repo_root = Path(__file__).resolve().parents[1]
site_dir = repo_root.parent / 'secubox-website'
targets = [site_dir / 'index.html', site_dir / 'campaign.html']
overall = False
for html in targets:
if not html.exists():
print(f'Skipping missing file: {html}', file=sys.stderr)
continue
if update_website(html):
print(f'Updated {html.name}')
overall = True
print('Website progress sync', 'done' if overall else 'no changes')
return 0
if __name__ == '__main__':
raise SystemExit(main())