Render the database ERD as a searchable Mermaid diagram instead of an image - #72006
Render the database ERD as a searchable Mermaid diagram instead of an image#72006ColtenOuO wants to merge 1 commit into
Conversation
… image The ERD reference pages embedded the schema as an SVG image, so table and column names weren't indexed by search engines or full-text search. The generate_erd Sphinx extension already regenerates the diagram from the live SQLAlchemy models on every doc build, so switching its output format doesn't introduce any new staleness risk. eralchemy (already a doc-build dependency) can emit Mermaid ER-diagram markup directly, removing the need for the graphviz system package during doc generation.
|
Two follow-up items I'd like reviewer input on — neither blocks this PR. 1. CI doesn't catch changes to
|
Sumarry
Render the database ERD reference pages (core, FAB, Edge3) as a Mermaid
erDiagraminstead of an SVG image, so table and column names are indexed by search engines and in-page search instead of being locked inside a picture.closes: #36842
Before / after
Before — the current production docs (
apache-airflow3.4.0) embed the ERD as a flat SVG image. On a schema this size (57 core tables) the image is dense and hard to read even at full screen, and none of the table/column text is selectable or searchable:After — same page, rendered as a Mermaid diagram from this branch. Every table/column name is now real page text: here the browser's in-page search (
Cmd+F) for "INTEGER" finds 50 matches on the FAB provider's ERD page:Same on the Edge3 provider's ERD page (a much smaller schema, so also easier to read as a bonus) — 7 matches for "INTEGER":
What changed
generate_erd(the Sphinx extension that (re)builds the diagram from the live SQLAlchemy models on every doc build) now writes Mermaid ER-diagram markup (.mmd) instead of an SVG.database-erd-ref.rstpages (airflow-core,providers/fab,providers/edge3) use the.. mermaid::directive (already available viasphinxcontrib-mermaid, already used elsewhere in the docs) instead of.. image::.dotavailability check and its SVG placeholder — Mermaid markup is emitted directly byeralchemywithout shelling out to graphviz, so that whole fallback path no longer applies..gitignoreandcontributing-docs/14_metadata_database_updates.rstfor the new generated filename.Why this wasn't done sooner
An earlier attempt (#42323) stalled because it tried to introduce a new tool (
paracelsus) and wasn't sure whether generating from live models vs. the post-migration database would let the diagram drift out of sync with the models. Both concerns are now moot:generate_erdalready regenerates from the live SQLAlchemyMetaDataon every doc build (introduced after that PR), and theeralchemyversion already pinned indevel-common(eralchemy==1.7.0) can emit Mermaid ER-diagram markup directly — no new dependency needed.Note:
eralchemy's ownrender_er(..., mode="mermaid_er")wraps its output in an HTML comment plus amermaid.ink-hosted image link (meant for GitHub-flavored markdown READMEs), which isn't right for a Sphinx.. mermaid::directive and would reintroduce an external-image dependency. This PR calls eralchemy's lower-levelall_to_intermediary/filter_resources/_intermediary_to_mermaid_erfunctions directly to get the rawerDiagram ...markup instead.Testing
breeze build-docs --package-filter apache-airflow --package-filter apache-airflow-providers-fab --package-filter apache-airflow-providers-edge3— build and spellcheck succeeded for all three, and the rendered HTML contains the ERD text (e.g.dag_run) directly in the page rather than in an image, with nomermaid.inkreference.prek run --stage pre-commitpasses on the changed files, includingmypyfordevel-common.Was generative AI tooling used to co-author this PR?