docs site from scratch with languages.yml control #1
@@ -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/
|
||||
|
||||
@@ -1 +1 @@
|
||||
# Coming soon
|
||||
# CLI Reference
|
||||
|
||||
@@ -1 +1 @@
|
||||
# Coming soon
|
||||
# Contributing to Core
|
||||
|
||||
@@ -1 +1 @@
|
||||
# Coming soon
|
||||
# Contributing Language Packs
|
||||
|
||||
@@ -1 +1 @@
|
||||
# Coming soon
|
||||
# Custom Packs
|
||||
|
||||
@@ -1 +1 @@
|
||||
# Coming soon
|
||||
# Architecture
|
||||
|
||||
@@ -1 +1 @@
|
||||
# Coming soon
|
||||
# Releasing
|
||||
|
||||
@@ -1 +1 @@
|
||||
# Coming soon
|
||||
# Getting Started
|
||||
|
||||
1
docs/language-packs/index.md
Normal file
1
docs/language-packs/index.md
Normal file
@@ -0,0 +1 @@
|
||||
# Language Packs
|
||||
1
docs/language-packs/template.md
Normal file
1
docs/language-packs/template.md
Normal file
@@ -0,0 +1 @@
|
||||
# Add Your Language
|
||||
@@ -1 +1 @@
|
||||
# Coming soon
|
||||
# Postfix Syntax
|
||||
|
||||
10
languages.yml
Normal file
10
languages.yml
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user