Skip to content

Commit c7cc10e

Browse files
authored
Reload the page for each screen size (sphinx-themes#148)
1 parent 4cf3f72 commit c7cc10e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/generate_screenshots.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@ def render_into_template(
5858
# --------------------------------------------------------------------------------------
5959
# Browser Interactions
6060
# --------------------------------------------------------------------------------------
61-
async def take_screenshots_at_all_resolutions(page: Page) -> Dict[str, Image.Image]:
61+
async def take_screenshots_at_all_resolutions(
62+
page: Page, url: str
63+
) -> Dict[str, Image.Image]:
6264
screenshots = {}
6365

6466
for name, resolution in SCREENSHOT_SIZES.items():
6567
await page.set_viewport_size(resolution)
68+
await page.goto(url, wait_until="load")
6669
await asyncio.sleep(1) # give the rendering logic a moment
6770

6871
size = (resolution["width"], resolution["height"])
@@ -84,12 +87,8 @@ async def render_at_multiple_resolutions(
8487
page = await context.new_page()
8588
progress.advance(task, 1)
8689

87-
# progress.log(f"{theme.name}: Navigating to local URL.")
88-
await page.goto(theme.url, wait_until="load")
89-
progress.advance(task, 2)
90-
9190
# progress.log(f"{theme.name}: Taking screenshots.")
92-
screenshots = await take_screenshots_at_all_resolutions(page)
91+
screenshots = await take_screenshots_at_all_resolutions(page, theme.url)
9392
progress.advance(task, 5)
9493

9594
# progress.log(f"{theme.name}: Rendering to template.")

0 commit comments

Comments
 (0)