docs site from scratch with languages.yml control

This commit is contained in:
2026-05-20 22:01:15 -05:00
parent dafb91970b
commit 1245333858
13 changed files with 94 additions and 16 deletions

View File

@@ -3,6 +3,7 @@ name: Deploy Docs
on:
push:
branches: ["main"]
workflow_dispatch:
jobs:
deploy:
@@ -19,6 +20,76 @@ jobs:
- name: Install MkDocs
run: pip install -r requirements.txt
- name: Fetch language READMEs and update nav
env:
GITEA_URL: https://git.keshavanand.net
ORG: foreign-thon
run: |
python3 << 'PYEOF'
import urllib.request
import json
import os
import re
gitea_url = os.environ["GITEA_URL"]
org = os.environ["ORG"]
# Read languages.yml manually (no yaml dep needed)
with open("languages.yml") as f:
lines = f.readlines()
languages = []
current = {}
for line in lines:
line = line.strip()
if line.startswith("- code:"):
if current:
languages.append(current)
current = {"code": line.split(":", 1)[1].strip()}
elif line.startswith("name:") and current:
current["name"] = line.split(":", 1)[1].strip()
elif line.startswith("repo:") and current:
current["repo"] = line.split(":", 1)[1].strip()
if current:
languages.append(current)
nav_lines = []
for lang in languages:
code = lang["code"]
name = lang["name"]
repo = lang["repo"]
readme_url = f"{gitea_url}/{org}/{repo}/raw/branch/main/README.md"
try:
with urllib.request.urlopen(readme_url) as r:
content = r.read().decode("utf-8")
out_path = f"docs/language-packs/{code}.md"
with open(out_path, "w", encoding="utf-8") as f:
f.write(content)
nav_lines.append(f" - '{name} ({code})': language-packs/{code}.md")
print(f"✓ {repo} → {out_path}")
except Exception as e:
print(f"✗ {repo}: {e}")
# Inject into mkdocs.yml between markers
with open("mkdocs.yml") as f:
yml = f.read()
nav_block = "\n".join(nav_lines)
new_yml = re.sub(
r" # LANGS_NAV_START.*?# LANGS_NAV_END",
f" # LANGS_NAV_START\n{nav_block}\n # LANGS_NAV_END",
yml,
flags=re.DOTALL
)
with open("mkdocs.yml", "w") as f:
f.write(new_yml)
print(f"Nav updated with {len(nav_lines)} languages.")
PYEOF
- name: Build
run: mkdocs build --strict
@@ -32,12 +103,7 @@ jobs:
echo "$SSH_DEPLOY_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -H $SERVER_HOST >> ~/.ssh/known_hosts
# Empties the folder safely without triggering Zsh glob errors
# and without needing root permissions on /var/www
ssh -i ~/.ssh/deploy_key $SERVER_USER@$SERVER_HOST \
"find /var/www/foreignthon-docs -mindepth 1 -delete"
# Copy built site
"rm -rf /var/www/foreignthon-docs/* && mkdir -p /var/www/foreignthon-docs"
scp -i ~/.ssh/deploy_key -r site/* \
$SERVER_USER@$SERVER_HOST:/var/www/foreignthon-docs/

View File

@@ -1 +1 @@
# Coming soon
# CLI Reference

View File

@@ -1 +1 @@
# Coming soon
# Contributing to Core

View File

@@ -1 +1 @@
# Coming soon
# Contributing Language Packs

View File

@@ -1 +1 @@
# Coming soon
# Custom Packs

View File

@@ -1 +1 @@
# Coming soon
# Architecture

View File

@@ -1 +1 @@
# Coming soon
# Releasing

View File

@@ -1 +1 @@
# Coming soon
# Getting Started

View File

@@ -0,0 +1 @@
# Language Packs

View File

@@ -0,0 +1 @@
# Add Your Language

View File

@@ -1 +1 @@
# Coming soon
# Postfix Syntax

10
languages.yml Normal file
View File

@@ -0,0 +1,10 @@
# Languages listed here get their README fetched from their repo
# and included in the docs site. Only add stable, complete packs.
languages:
- code: es
name: Spanish
repo: foreignthon-es
- code: ta
name: Tamil
repo: foreignthon-ta

View File

@@ -34,8 +34,8 @@ nav:
- Custom Packs: custom-packs.md
- Language Packs:
- Overview: language-packs/index.md
- Spanish (es): language-packs/es.md
- Tamil (ta): language-packs/ta.md
# LANGS_NAV_START
# LANGS_NAV_END
- Add your language: language-packs/template.md
- Contributing:
- Core: contributing/core.md