fix: keep .mdx pages through the sweep

A body is written as .md and the decoration pass, after the sweep,
gives a page with components its .mdx name. The sweep did not count the
.mdx of the run before as produced: 402 pages were deleted and written
again on every run, so write_if_changed never kept their bytes.
This commit is contained in:
Abdessamad Derraz committed 2026-11-11 10:27:53 +01:00
1 parent 8d69ad54df
commit ecfe8157bb
2 files changed
+32 -3

No files matched your search

+15
View File
@@ -120,6 +120,21 @@ class Sweep(unittest.TestCase):
self.assertTrue((self.docs / "emulators/kept.md").exists())
self.assertTrue((self.docs / "emulators/nested/deep.md").exists())
def test_a_page_the_decoration_pass_made_mdx_is_kept(self):
"""A body is written as .md, and the decoration pass, after the
sweep, renames a page with components to .mdx. The .mdx of the run
before was swept and written again on every run: 402 pages."""
(self.docs / "platforms/kept.mdx").write_text("x")
(self.docs / "platforms/gone.mdx").write_text("x")
self._produce("platforms/kept.md")
sitewrite._sweep_generated(self.docs, ["platforms"])
(self.docs / "top.mdx").write_text("x")
sitewrite._record(self.docs / "top.md")
self.assertEqual(sitewrite._sweep_top_pages(self.docs), 0)
self.assertTrue((self.docs / "platforms/kept.mdx").exists())
self.assertTrue((self.docs / "top.mdx").exists())
self.assertFalse((self.docs / "platforms/gone.mdx").exists())
def test_a_directory_outside_the_list_is_never_touched(self):
self._produce("emulators/kept.md", "emulators/nested/deep.md",
"emulators/stale.md")