mirror of https://github.com/tiangolo/fastapi.git
🔨 Verify `mkdocs.yml` languages in CI, update `docs.py` (#11009)
This commit is contained in:
parent
60ea8f85a1
commit
2fe1a1387b
|
|
@ -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/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/griffe-typing-deprecated.git
|
||||||
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git
|
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git
|
||||||
- name: Verify README
|
- name: Verify Docs
|
||||||
run: python ./scripts/docs.py verify-readme
|
run: python ./scripts/docs.py verify-docs
|
||||||
- name: Export Language Codes
|
- name: Export Language Codes
|
||||||
id: show-langs
|
id: show-langs
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ markdown_extensions:
|
||||||
format: !!python/name:pymdownx.superfences.fence_code_format ''
|
format: !!python/name:pymdownx.superfences.fence_code_format ''
|
||||||
pymdownx.tabbed:
|
pymdownx.tabbed:
|
||||||
alternate_style: true
|
alternate_style: true
|
||||||
pymdownx.tilde:
|
pymdownx.tilde: null
|
||||||
attr_list: null
|
attr_list: null
|
||||||
md_in_html: null
|
md_in_html: null
|
||||||
extra:
|
extra:
|
||||||
|
|
@ -267,6 +267,8 @@ extra:
|
||||||
alternate:
|
alternate:
|
||||||
- link: /
|
- link: /
|
||||||
name: en - English
|
name: en - English
|
||||||
|
- link: /bn/
|
||||||
|
name: bn - বাংলা
|
||||||
- link: /de/
|
- link: /de/
|
||||||
name: de - Deutsch
|
name: de - Deutsch
|
||||||
- link: /es/
|
- link: /es/
|
||||||
|
|
@ -304,7 +306,7 @@ extra:
|
||||||
- link: /zh/
|
- link: /zh/
|
||||||
name: zh - 汉语
|
name: zh - 汉语
|
||||||
- link: /zh-hant/
|
- link: /zh-hant/
|
||||||
name: zh - 繁體中文
|
name: zh-hant - 繁體中文
|
||||||
- link: /em/
|
- link: /em/
|
||||||
name: 😉
|
name: 😉
|
||||||
extra_css:
|
extra_css:
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@ set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
# Check README.md is up to date
|
# 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
|
python ./scripts/docs.py build-all
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ def live(
|
||||||
mkdocs.commands.serve.serve(dev_addr="127.0.0.1:8008")
|
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()
|
config = get_en_config()
|
||||||
languages = [{"en": "/"}]
|
languages = [{"en": "/"}]
|
||||||
new_alternate: List[Dict[str, str]] = []
|
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": url, "name": use_name})
|
||||||
new_alternate.append({"link": "/em/", "name": "😉"})
|
new_alternate.append({"link": "/em/", "name": "😉"})
|
||||||
config["extra"]["alternate"] = new_alternate
|
config["extra"]["alternate"] = new_alternate
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
def update_config() -> None:
|
||||||
|
config = get_updated_config_content()
|
||||||
en_config_path.write_text(
|
en_config_path.write_text(
|
||||||
yaml.dump(config, sort_keys=False, width=200, allow_unicode=True),
|
yaml.dump(config, sort_keys=False, width=200, allow_unicode=True),
|
||||||
encoding="utf-8",
|
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()
|
@app.command()
|
||||||
def langs_json():
|
def langs_json():
|
||||||
langs = []
|
langs = []
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue