refactor: print sizes with one function

core.sizes.size_text replaces readme format_size, release record
size_text, render fmt_size, the large-files notes _mib and the handheld
_size. It prints one decimal in the largest unit reached, as the site
and the installer already did.

The README download table, the release notes and the large-files page
now say 29.2 MB where they said 29 MB, a handheld archive says 85.3 KB
where it said 85 KB, and a large-files asset under 1 MB is given in KB.
This commit is contained in:
Abdessamad Derraz committed 2026-11-20 20:03:26 +01:00
1 parent 3a76cf48ba
commit ab0805e6cb
19 files changed
+60 -71

No files matched your search

+4 -3
View File
@@ -13,7 +13,8 @@ from model.safeparse import yaml_load
from sitegen import markup, measurements as sitemeasurements
from sitegen.config import RELEASE_URL, REPO_URL, SITE_URL
from core.paths import REPO_ROOT
from sitegen.render import escape_tags, fmt_size
from core.sizes import size_text
from sitegen.render import escape_tags
def _is_manifest(item: dict) -> bool:
@@ -178,7 +179,7 @@ def generate_data_page(exports: list[dict], measurements_sqlite: Path | None = N
)
lines.append(
f"| {item['title']} | [`{item['url']}`]({item['url']}) | "
f"{schema} | {fmt_size(item['bytes'])} |"
f"{schema} | {size_text(item['bytes'])} |"
)
lines.extend([
"",
@@ -354,7 +355,7 @@ def generate_data_page(exports: list[dict], measurements_sqlite: Path | None = N
continue
lines.append(
f"| [{item['title']}]({item['url']}) | `{item['media_type']}` | "
f"{fmt_size(item['bytes'])} | {_short_sha256(item, 'api/v1/catalog.json')} |"
f"{size_text(item['bytes'])} | {_short_sha256(item, 'api/v1/catalog.json')} |"
)
lines.extend([
"",