diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index e85c3e1..b092b48 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -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/ diff --git a/docs/cli-reference.md b/docs/cli-reference.md index 91f12c9..c31a0bc 100644 --- a/docs/cli-reference.md +++ b/docs/cli-reference.md @@ -1 +1 @@ -# Coming soon +# CLI Reference diff --git a/docs/contributing/core.md b/docs/contributing/core.md index 91f12c9..e8a4e40 100644 --- a/docs/contributing/core.md +++ b/docs/contributing/core.md @@ -1 +1 @@ -# Coming soon +# Contributing to Core diff --git a/docs/contributing/language-packs.md b/docs/contributing/language-packs.md index 91f12c9..ad03e25 100644 --- a/docs/contributing/language-packs.md +++ b/docs/contributing/language-packs.md @@ -1 +1 @@ -# Coming soon +# Contributing Language Packs diff --git a/docs/custom-packs.md b/docs/custom-packs.md index 91f12c9..666aeda 100644 --- a/docs/custom-packs.md +++ b/docs/custom-packs.md @@ -1 +1 @@ -# Coming soon +# Custom Packs diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index 91f12c9..c79bec1 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -1 +1 @@ -# Coming soon +# Architecture diff --git a/docs/dev/releasing.md b/docs/dev/releasing.md index 91f12c9..af81e9e 100644 --- a/docs/dev/releasing.md +++ b/docs/dev/releasing.md @@ -1 +1 @@ -# Coming soon +# Releasing diff --git a/docs/getting-started.md b/docs/getting-started.md index 91f12c9..bad5562 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1 +1 @@ -# Coming soon +# Getting Started diff --git a/docs/language-packs/index.md b/docs/language-packs/index.md new file mode 100644 index 0000000..40c029e --- /dev/null +++ b/docs/language-packs/index.md @@ -0,0 +1 @@ +# Language Packs diff --git a/docs/language-packs/template.md b/docs/language-packs/template.md new file mode 100644 index 0000000..def0bb2 --- /dev/null +++ b/docs/language-packs/template.md @@ -0,0 +1 @@ +# Add Your Language diff --git a/docs/postfix-syntax.md b/docs/postfix-syntax.md index 91f12c9..eeeca72 100644 --- a/docs/postfix-syntax.md +++ b/docs/postfix-syntax.md @@ -1 +1 @@ -# Coming soon +# Postfix Syntax diff --git a/languages.yml b/languages.yml new file mode 100644 index 0000000..2e90aae --- /dev/null +++ b/languages.yml @@ -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 diff --git a/mkdocs.yml b/mkdocs.yml index 7ebe436..e5f8ba0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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