-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_all.py
More file actions
executable file
·164 lines (145 loc) · 4.98 KB
/
build_all.py
File metadata and controls
executable file
·164 lines (145 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env python3
"""
Build all language versions of the omegaUp documentation site.
This script builds the documentation for all configured languages
(English, Spanish, Portuguese, and Brazilian Portuguese).
Before building, runs scripts/verify_docs_nav.py (every .md is listed in nav).
After a successful build, runs scripts/verify_docs_rendered.py (every .md has HTML output).
"""
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).parent
VERIFY_NAV = ROOT / "scripts" / "verify_docs_nav.py"
VERIFY_RENDERED = ROOT / "scripts" / "verify_docs_rendered.py"
CONFIG_FILES = [
"zensical.toml", # English
"zensical.es.toml", # Spanish
"zensical.pt.toml", # Portuguese
"zensical.pt-BR.toml", # Brazilian Portuguese
]
# Check for virtual environment
VENV_DIR = ROOT / ".venv"
if VENV_DIR.exists():
PYTHON = str(VENV_DIR / "bin" / "python3")
ZENSICAL = str(VENV_DIR / "bin" / "zensical")
else:
PYTHON = "python3"
ZENSICAL = "zensical"
def run_command(cmd, description):
"""Run a command and handle errors."""
print(f"\n{'='*60}")
print(f"🔨 {description}")
print(f"{'='*60}")
try:
result = subprocess.run(
cmd,
cwd=ROOT,
check=True,
capture_output=False,
text=True
)
print(f"✅ {description} - SUCCESS")
return True
except subprocess.CalledProcessError as e:
print(f"❌ {description} - FAILED")
return False
def main():
print("🌍 Building omegaUp Documentation - All Languages")
print(f"📂 Working directory: {ROOT}")
if not VERIFY_NAV.is_file():
print(f"❌ Missing {VERIFY_NAV.name}; cannot verify navigation coverage.")
return 1
if not run_command(
[PYTHON, str(VERIFY_NAV)],
"Verifying nav covers every markdown page (all locales)",
):
print(
"\nFix orphan pages in zensical*.toml, then rebuild. "
"See scripts/verify_docs_nav.py for rules."
)
return 1
# Clean the site directory first
print("\n🧹 Cleaning site directory...")
site_dir = ROOT / "site"
if site_dir.exists():
import shutil
shutil.rmtree(site_dir)
print(" Removed existing site/ directory")
# Build each language
failures = []
for config in CONFIG_FILES:
lang = config.replace("zensical.", "").replace(".toml", "")
if lang == "toml": # zensical.toml -> "en"
lang = "en"
config_path = ROOT / config
if not config_path.exists():
print(f"⚠️ Config file not found: {config}")
failures.append(lang)
continue
success = run_command(
[ZENSICAL, "build", "--clean", "--config-file", config],
f"Building {lang.upper()} documentation"
)
if not success:
failures.append(lang)
# Create root redirect to /en/
print("\n🔗 Creating root redirect...")
redirect_html = """<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="refresh" content="0; url=./en/" />
<link rel="icon" href="./en/assets/images/favicon-76x76.png" type="image/png" />
<link rel="canonical" href="./en/" />
<title>omegaUp Documentation</title>
<script>
(function() {
location.replace('./en/');
})();
</script>
</head>
<body>
<p>Redirecting to <a href="./en/">English documentation</a>…</p>
</body>
</html>
"""
index_file = ROOT / "site" / "index.html"
index_file.write_text(redirect_html, encoding="utf-8")
print(" Created site/index.html redirect")
# Summary
print("\n" + "="*60)
if failures:
print("⚠️ Build completed with errors")
print(f" Failed languages: {', '.join(failures)}")
return 1
if not VERIFY_RENDERED.is_file():
print(f"❌ Missing {VERIFY_RENDERED.name}; cannot verify rendered HTML.")
return 1
if not run_command(
[PYTHON, str(VERIFY_RENDERED)],
"Verifying every markdown page produced HTML (all locales)",
):
print(
"\nSome source pages are missing from site/. "
"See scripts/verify_docs_rendered.py."
)
return 1
print("✅ All language versions built successfully!")
print("\n📚 Available languages:")
print(" • English: site/en/")
print(" • Español: site/es/")
print(" • Português: site/pt/")
print(" • Português (Brasil): site/pt-BR/")
print("\n🚀 To serve locally, run:")
print(" python3 serve_multilang.py")
print(" or")
print(" cd site && python3 -m http.server 8000")
return 0
if __name__ == "__main__":
try:
sys.exit(main())
except KeyboardInterrupt:
print("\n\n⚠️ Build interrupted by user")
sys.exit(130)