| 2851 | |
| 2852 | |
| 2853 | def test_agents_md_docs_paths_exist(shipped_agents_md): |
| 2854 | # Index lines end with a docs path relative to https://docs.crewai.com/en/. |
| 2855 | links = re.findall( |
| 2856 | r"`([a-z]+(?:/[a-z0-9-]+)+)(?:#([a-z0-9-]+))?`\s*$", shipped_agents_md, re.M |
| 2857 | ) |
| 2858 | assert links, "AGENTS.md links no docs pages to check" |
| 2859 | nav = (DOCS / "docs.json").read_text(encoding="utf-8") |
| 2860 | for page, anchor in links: |
| 2861 | assert f'"edge/en/{page}"' in nav, f"{page} is not in the docs nav" |
| 2862 | if anchor: |
| 2863 | mdx = (DOCS / "edge/en" / f"{page}.mdx").read_text(encoding="utf-8") |
| 2864 | headings = re.findall(r"^#+ (.+)$", mdx, re.M) |
| 2865 | slugs = {re.sub(r"[^a-z0-9]+", "-", h.lower()).strip("-") for h in headings} |
| 2866 | assert anchor in slugs, f"{page} has no #{anchor} heading" |