kaxil opened a new pull request, #77257:
URL: https://github.com/apache/airflow/pull/77257

   The [database 
ERD](https://airflow.apache.org/docs/apache-airflow/stable/database-erd-ref.html)
 is about 12000x8000 px, and the page squeezes it into the ~850 px text column, 
so you can't read a single column name. There's also no way out of that view: 
it's an `<object>` (no "open image in new tab" like the old `<img>`), and the 
SVG has `width="100%"`, so opening the file directly shrinks it to the window 
again and browser zoom does nothing.
   
   This PR makes every mermaid diagram in the docs a link to its SVG, and has 
mermaid draw the SVG at its real pixel size (`useMaxWidth: false` for `er`, 
`flowchart` and `sequence`, the only types the docs use). In the page it still 
scales to the column via `max-width: 100%`. Click it and the browser opens the 
full-size SVG, where scrolling and Cmd/Ctrl +/- work. I added a sentence to the 
ERD page saying you can click it.
   
   I looked at sphinxcontrib-mermaid's `:zoom:` and `mermaid_fullscreen` first. 
They only work with `raw` output, which loads mermaid and d3 from 
cdn.jsdelivr.net, and the ASF CSP blocks that (the reason #74757 moved to 
build-time SVG). Vendoring a pan/zoom script into `_static` would get past the 
CSP, but a plain link gets the browser's own zoom with no JS to ship or license.
   
   To add the link, `mermaid_svg.py` now registers its own HTML visitor for the 
`mermaid` node in place of sphinxcontrib's svg branch, which only emitted the 
bare `<object>`. A failing `mmdc` still logs `Mermaid exited with error` and 
fails the build, and a missing `mmdc` still gets sphinxcontrib's warning. The 
styles are inline so the provider and SDK docs don't each need a stylesheet; 
the airflow.apache.org CSP allows inline styles.
   
   How it got this way: #72006 switched the ERD from an `<img>` to mermaid, and 
#74757 embedded mermaid SVGs as an `<object>` scaled to page width.
   
   I ran a clean `breeze build-docs apache-airflow` and served it locally with 
the ASF CSP header. The ERD sits at 867x579 in the column with a zoom-in 
cursor, clicking opens the 12065x8061 SVG, and there were no CSP violations in 
the console. Diagrams on the security and JWT pages render at the same sizes as 
before.
   
   <!-- screenshot: erd-page.png (the ERD in the page) -->
   
   <!-- screenshot: erd-full.png (after clicking) -->
   
   If you build locally into an existing build dir, run `--clean-build` once: 
sphinxcontrib-mermaid caches each SVG by diagram source and config file path, 
not the config contents, so old `width="100%"` SVGs stick around otherwise.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to