|
|
@ -1,3 +1,4 @@ |
|
|
|
import json |
|
|
|
import os |
|
|
|
import re |
|
|
|
import shutil |
|
|
@ -133,12 +134,15 @@ def build_lang( |
|
|
|
build_lang_path = build_dir_path / lang |
|
|
|
en_lang_path = Path("docs/en") |
|
|
|
site_path = Path("site").absolute() |
|
|
|
build_site_path = Path("site_build").absolute() |
|
|
|
build_site_dist_path = build_site_path / lang |
|
|
|
if lang == "en": |
|
|
|
dist_path = site_path |
|
|
|
else: |
|
|
|
dist_path: Path = site_path / lang |
|
|
|
shutil.rmtree(build_lang_path, ignore_errors=True) |
|
|
|
shutil.copytree(lang_path, build_lang_path) |
|
|
|
if not lang == "en": |
|
|
|
shutil.copytree(en_docs_path / "data", build_lang_path / "data") |
|
|
|
overrides_src = en_docs_path / "overrides" |
|
|
|
overrides_dest = build_lang_path / "overrides" |
|
|
@ -147,7 +151,9 @@ def build_lang( |
|
|
|
if not dest_path.exists(): |
|
|
|
shutil.copy(path, dest_path) |
|
|
|
en_config_path: Path = en_lang_path / mkdocs_name |
|
|
|
en_config: dict = mkdocs.utils.yaml_load(en_config_path.read_text(encoding="utf-8")) |
|
|
|
en_config: dict = mkdocs.utils.yaml_load( |
|
|
|
en_config_path.read_text(encoding="utf-8") |
|
|
|
) |
|
|
|
nav = en_config["nav"] |
|
|
|
lang_config_path: Path = lang_path / mkdocs_name |
|
|
|
lang_config: dict = mkdocs.utils.yaml_load( |
|
|
@ -201,7 +207,10 @@ def build_lang( |
|
|
|
) |
|
|
|
current_dir = os.getcwd() |
|
|
|
os.chdir(build_lang_path) |
|
|
|
subprocess.run(["mkdocs", "build", "--site-dir", dist_path], check=True) |
|
|
|
shutil.rmtree(build_site_dist_path, ignore_errors=True) |
|
|
|
shutil.rmtree(dist_path, ignore_errors=True) |
|
|
|
subprocess.run(["mkdocs", "build", "--site-dir", build_site_dist_path], check=True) |
|
|
|
shutil.copytree(build_site_dist_path, dist_path, dirs_exist_ok=True) |
|
|
|
os.chdir(current_dir) |
|
|
|
typer.secho(f"Successfully built docs for: {lang}", color=typer.colors.GREEN) |
|
|
|
|
|
|
@ -271,18 +280,8 @@ def build_all(): |
|
|
|
Build mkdocs site for en, and then build each language inside, end result is located |
|
|
|
at directory ./site/ with each language inside. |
|
|
|
""" |
|
|
|
site_path = Path("site").absolute() |
|
|
|
update_languages(lang=None) |
|
|
|
current_dir = os.getcwd() |
|
|
|
os.chdir(en_docs_path) |
|
|
|
typer.echo("Building docs for: en") |
|
|
|
subprocess.run(["mkdocs", "build", "--site-dir", site_path], check=True) |
|
|
|
os.chdir(current_dir) |
|
|
|
langs = [] |
|
|
|
for lang in get_lang_paths(): |
|
|
|
if lang == en_docs_path or not lang.is_dir(): |
|
|
|
continue |
|
|
|
langs.append(lang.name) |
|
|
|
langs = [lang.name for lang in get_lang_paths() if lang.is_dir()] |
|
|
|
cpu_count = os.cpu_count() or 1 |
|
|
|
process_pool_size = cpu_count * 4 |
|
|
|
typer.echo(f"Using process pool size: {process_pool_size}") |
|
|
@ -397,6 +396,15 @@ def update_config(lang: str): |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
@app.command() |
|
|
|
def langs_json(): |
|
|
|
langs = [] |
|
|
|
for lang_path in get_lang_paths(): |
|
|
|
if lang_path.is_dir(): |
|
|
|
langs.append(lang_path.name) |
|
|
|
print(json.dumps(langs)) |
|
|
|
|
|
|
|
|
|
|
|
def get_key_section( |
|
|
|
*, key_to_section: Dict[Tuple[str, ...], list], key: Tuple[str, ...] |
|
|
|
) -> list: |
|
|
|