Skip to content

Commit 6b0e1bc

Browse files
authored
Merge pull request #1274 from pypa/diagram-fix
2 parents 7969f7c + 728e371 commit 6b0e1bc

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed

bin/update_how_it_works_image.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python3
2+
3+
from __future__ import annotations
4+
5+
import subprocess
6+
import sys
7+
from pathlib import Path
8+
9+
try:
10+
from html2image import Html2Image # type: ignore[import]
11+
except ImportError:
12+
sys.exit(
13+
"""
14+
html2image not found. Ensure you have Chrome (on Mac/Windows) or
15+
Chromium (on Linux) installed, and then do:
16+
pip install html2image
17+
"""
18+
)
19+
20+
21+
def main():
22+
subprocess.run(["mkdocs", "build"])
23+
24+
hti = Html2Image(custom_flags=["--force-device-scale-factor=2"])
25+
26+
html_str = Path("docs/diagram.md").read_text()
27+
css_tags = f"""
28+
<style>{Path("site/css/theme.css").read_text()}</style>
29+
<style>{Path("site/css/theme_extra.css").read_text()}</style>
30+
<style>{Path("site/extra.css").read_text()}</style>
31+
<style>
32+
body {{
33+
background: white;
34+
}}
35+
</style>
36+
"""
37+
html_str = css_tags + html_str
38+
39+
[screenshot, *_] = hti.screenshot(
40+
html_str=html_str,
41+
size=(830, 405),
42+
)
43+
44+
dest_path = Path("docs/data/how-it-works.png")
45+
if dest_path.exists():
46+
dest_path.unlink()
47+
48+
Path(screenshot).rename(dest_path)
49+
50+
51+
if __name__ == "__main__":
52+
main()

docs/data/how-it-works.png

-8.45 KB
Loading

docs/diagram.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</div>
3030
<div class="grid-column-label"
3131
style="grid-row: 2 / span 1;
32-
grid-column: 8 / -3;
32+
grid-column: 9 / -3;
3333
margin-bottom: 0.5em;">
3434
<div class="label">If tests are configured</div>
3535
</div>
@@ -382,7 +382,7 @@
382382
}
383383
.grid-column-label .label {
384384
background: #fcfcfc;
385-
padding: 0 2em;
385+
padding: 0 1em;
386386
position: relative;
387387
}
388388
.grid-row-label {
@@ -420,7 +420,7 @@
420420
grid-column: 3 / -2;
421421
}
422422
.grid-outline.testVenv {
423-
grid-column: 8 / span 4;
423+
grid-column: 9 / span 3;
424424
}
425425
.grid-outline .outline {
426426
position: absolute;

0 commit comments

Comments
 (0)