From: Sebastián Ramírez Date: Mon, 30 Mar 2020 18:41:50 +0000 (+0200) Subject: :wrench: Update docs script to make sure languages are always sorted (#1189) X-Git-Tag: 0.53.2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=06eaa32bf0a7e3272d5175c26645fe0845286180;p=thirdparty%2Ffastapi%2Ffastapi.git :wrench: Update docs script to make sure languages are always sorted (#1189) --- diff --git a/scripts/docs.py b/scripts/docs.py index 345135e91b..186a3e4f89 100644 --- a/scripts/docs.py +++ b/scripts/docs.py @@ -22,6 +22,10 @@ missing_translation_snippet = """ docs_path = Path("docs") +def get_lang_paths(): + return sorted(docs_path.iterdir()) + + def lang_callback(lang: Optional[str]): if lang is None: return @@ -34,7 +38,7 @@ def lang_callback(lang: Optional[str]): def complete_existing_lang(incomplete: str): lang_path: Path - for lang_path in docs_path.iterdir(): + for lang_path in get_lang_paths(): if lang_path.is_dir() and lang_path.name.startswith(incomplete): yield lang_path.name @@ -198,7 +202,7 @@ def build_all(): typer.echo(f"Building docs for: en") mkdocs.commands.build.build(mkdocs.config.load_config(site_dir=str(site_path))) os.chdir(current_dir) - for lang in docs_path.iterdir(): + for lang in get_lang_paths(): if lang == en_build_path or not lang.is_dir(): continue build_lang(lang.name) @@ -220,7 +224,7 @@ def update_languages( mkdocs.yml files (for all the languages). """ if lang is None: - for lang_path in docs_path.iterdir(): + for lang_path in get_lang_paths(): if lang_path.is_dir(): typer.echo(f"Updating {lang_path.name}") update_config(lang_path.name) @@ -278,7 +282,7 @@ def update_config(lang: str): config_path = lang_path / mkdocs_name config: dict = mkdocs.utils.yaml_load(config_path.read_text(encoding="utf-8")) languages = [{"en": "/"}] - for lang in docs_path.iterdir(): + for lang in get_lang_paths(): if lang.name == "en" or not lang.is_dir(): continue name = lang.name