def update_docs()

in scripts/internal/update_example_tables.py [0:0]


def update_docs(examples):
    with open("docs/source/resources.mdx", "r") as f:
        content = f.read()

    new_content = []
    ordered_services = ["Vertex AI", "GKE", "Cloud Run"]
    ordered_types = ["inference", "training", "evaluation"]

    for service in ordered_services:
        service_name = f"(Preview) {service}" if service == "Cloud Run" else service
        new_content.append(f"\n### {service_name}\n")

        for example_type in ordered_types:
            if examples[service].get(example_type):
                new_content.append(f"\n- {example_type.capitalize()}\n\n")
                for path, title in sorted(
                    examples[service][example_type], key=lambda x: x[1]
                ):
                    github_url = f"https://github.com/huggingface/Google-Cloud-Containers/tree/main/{path}"
                    new_content.append(f"  - [{title}]({github_url})\n")

    new_examples_content = "".join(new_content)

    # Replace the Examples section in the original content
    pattern = r"(## Examples\n\n- \[All examples\].*?\n)[\s\S]*"
    updated_content = re.sub(
        pattern, rf"\1{new_examples_content}", content, flags=re.DOTALL
    )

    with open("docs/source/resources.mdx", "w") as f:
        f.write(updated_content)