]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
🔨 Verify `mkdocs.yml` languages in CI, update `docs.py` (#11009)
authorSebastián Ramírez <tiangolo@gmail.com>
Mon, 22 Jan 2024 19:26:14 +0000 (20:26 +0100)
committerGitHub <noreply@github.com>
Mon, 22 Jan 2024 19:26:14 +0000 (20:26 +0100)
.github/workflows/build-docs.yml
docs/en/mkdocs.yml
scripts/build-docs.sh
scripts/docs.py

index abf2b90f688b207d6588bebce00efa288f9e7157..7783161b9f0cba4e301fede38ff0e363e3c5ceec 100644 (file)
@@ -57,8 +57,8 @@ jobs:
           pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
           pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/griffe-typing-deprecated.git
           pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git
-      - name: Verify README
-        run: python ./scripts/docs.py verify-readme
+      - name: Verify Docs
+        run: python ./scripts/docs.py verify-docs
       - name: Export Language Codes
         id: show-langs
         run: |
index fcac555eb6363b7ad1b97f1c114cdcc63f331a87..e965f4f28f25e2acfb7ecacce21a8098266b4ef8 100644 (file)
@@ -242,7 +242,7 @@ markdown_extensions:
       format: !!python/name:pymdownx.superfences.fence_code_format ''
   pymdownx.tabbed:
     alternate_style: true
-  pymdownx.tilde:
+  pymdownx.tilde: null
   attr_list: null
   md_in_html: null
 extra:
@@ -267,6 +267,8 @@ extra:
   alternate:
   - link: /
     name: en - English
+  - link: /bn/
+    name: bn - বাংলা
   - link: /de/
     name: de - Deutsch
   - link: /es/
@@ -304,7 +306,7 @@ extra:
   - link: /zh/
     name: zh - 汉语
   - link: /zh-hant/
-    name: zh - 繁體中文
+    name: zh-hant - 繁體中文
   - link: /em/
     name: 😉
 extra_css:
index ebf864afa3dac2eb1e0931cfed19d25c9bd83e3f..7aa0a9a47f83000e2f0b0b45b60f49dfd6b75727 100755 (executable)
@@ -4,5 +4,5 @@ set -e
 set -x
 
 # Check README.md is up to date
-python ./scripts/docs.py verify-readme
+python ./scripts/docs.py verify-docs
 python ./scripts/docs.py build-all
index 0643e414f52d71530c721576ce73fc90f9abd19d..59578a820ce6c021a9d3786bd49a5670c23e0c17 100644 (file)
@@ -266,7 +266,7 @@ def live(
     mkdocs.commands.serve.serve(dev_addr="127.0.0.1:8008")
 
 
-def update_config() -> None:
+def get_updated_config_content() -> Dict[str, Any]:
     config = get_en_config()
     languages = [{"en": "/"}]
     new_alternate: List[Dict[str, str]] = []
@@ -294,12 +294,42 @@ def update_config() -> None:
         new_alternate.append({"link": url, "name": use_name})
     new_alternate.append({"link": "/em/", "name": "😉"})
     config["extra"]["alternate"] = new_alternate
+    return config
+
+
+def update_config() -> None:
+    config = get_updated_config_content()
     en_config_path.write_text(
         yaml.dump(config, sort_keys=False, width=200, allow_unicode=True),
         encoding="utf-8",
     )
 
 
+@app.command()
+def verify_config() -> None:
+    """
+    Verify main mkdocs.yml content to make sure it uses the latest language names.
+    """
+    typer.echo("Verifying mkdocs.yml")
+    config = get_en_config()
+    updated_config = get_updated_config_content()
+    if config != updated_config:
+        typer.secho(
+            "docs/en/mkdocs.yml outdated from docs/language_names.yml, "
+            "update language_names.yml and run "
+            "python ./scripts/docs.py update-languages",
+            color=typer.colors.RED,
+        )
+        raise typer.Abort()
+    typer.echo("Valid mkdocs.yml ✅")
+
+
+@app.command()
+def verify_docs():
+    verify_readme()
+    verify_config()
+
+
 @app.command()
 def langs_json():
     langs = []