updated readmes
This commit is contained in:
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import html
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
@@ -73,6 +74,15 @@ def display_name_for_item(item_name: str) -> str:
|
||||
return item_name.replace("_", " ").title()
|
||||
|
||||
|
||||
def markdown_table_cell(text: str) -> str:
|
||||
return text.replace("|", "\\|").replace("\n", " ")
|
||||
|
||||
|
||||
def markdown_anchor(text: str) -> str:
|
||||
anchor = re.sub(r"[^a-z0-9]+", "-", text.lower()).strip("-")
|
||||
return anchor
|
||||
|
||||
|
||||
def collect_renameable_items(pack_root: Path) -> list[dict[str, Any]]:
|
||||
item_files = sorted(pack_root.glob("assets/*/items/*.json"))
|
||||
records: list[dict[str, Any]] = []
|
||||
@@ -155,6 +165,14 @@ def build_markdown(records: list[dict[str, Any]]) -> str:
|
||||
lines.append(f"- Rename variants: {total_cases}")
|
||||
lines.append("- Render mode: local Python renderer")
|
||||
lines.append("")
|
||||
lines.append("## Catalog")
|
||||
lines.append("")
|
||||
lines.append("| Item | Rename targets |")
|
||||
lines.append("| --- | ---: |")
|
||||
for record in records:
|
||||
display_name = display_name_for_item(record["item"])
|
||||
lines.append(f"| [{markdown_table_cell(display_name)}](#{markdown_anchor(display_name)}) | {len(record['cases'])} |")
|
||||
lines.append("")
|
||||
lines.append("Sections are sorted by the item they are generated from.")
|
||||
|
||||
for record in records:
|
||||
@@ -253,31 +271,39 @@ def build_namespace_catalog(records: list[dict[str, Any]], namespace: str) -> st
|
||||
lines.append("- Render mode: local Python renderer")
|
||||
lines.append("")
|
||||
|
||||
lines.append("## Catalog")
|
||||
lines.append("")
|
||||
lines.append("| Item | Rename targets |")
|
||||
lines.append("| --- | ---: |")
|
||||
|
||||
for record in namespace_records:
|
||||
display_name = display_name_for_item(record["item"])
|
||||
namespace_cases = [case for case in record["cases"] if case_namespace(case) == namespace]
|
||||
lines.append(f"| [{markdown_table_cell(display_name)}](#{markdown_anchor(display_name)}) | {len(namespace_cases)} |")
|
||||
|
||||
lines.append("")
|
||||
|
||||
for record in namespace_records:
|
||||
display_name = display_name_for_item(record["item"])
|
||||
namespace_cases = [case for case in record["cases"] if case_namespace(case) == namespace]
|
||||
|
||||
lines.append(f"## {display_name}")
|
||||
lines.append("")
|
||||
lines.append(f"- Generated from: `{record['source_file']}`")
|
||||
lines.append(f"- Fallback model: `{record['fallback_model']}`")
|
||||
|
||||
lines.append("")
|
||||
lines.append("### Rename variants")
|
||||
lines.append("")
|
||||
|
||||
namespace_cases = [case for case in record["cases"] if case_namespace(case) == namespace]
|
||||
|
||||
if not namespace_cases:
|
||||
lines.append("- None found")
|
||||
lines.append("")
|
||||
continue
|
||||
lines.append("| Icon | Rename to |")
|
||||
lines.append("| --- | --- |")
|
||||
|
||||
for case in namespace_cases:
|
||||
if case["render_path"]:
|
||||
lines.append(f"- `{case['when']}` -> `{case['model']}`")
|
||||
lines.append(f" - Preview: <img src=\"{case['render_path']}\" alt=\"{case['when']}\" width=\"160\" />")
|
||||
icon = f'<img src="{case["render_path"]}" alt="{markdown_table_cell(case["when"])}" width="72" />'
|
||||
else:
|
||||
lines.append(f"- `{case['when']}` -> `{case['model']}` (not present yet)")
|
||||
icon = "render pending"
|
||||
|
||||
lines.append(
|
||||
f"| {icon} | {markdown_table_cell(case['when'])} |"
|
||||
)
|
||||
|
||||
if not namespace_cases:
|
||||
lines.append("| render pending | None found |")
|
||||
|
||||
lines.append("")
|
||||
|
||||
@@ -306,8 +332,7 @@ def build_html(records: list[dict[str, Any]]) -> str:
|
||||
preview_items.append(
|
||||
"<article class='variant'>"
|
||||
f"<div class='variant-preview'>{preview}</div>"
|
||||
f"<div class='variant-name'>{html.escape(case['when'])}</div>"
|
||||
f"<div class='variant-model'>{html.escape(case['model'])}</div>"
|
||||
f"<div class='variant-name'>Rename to: {html.escape(case['when'])}</div>"
|
||||
"</article>"
|
||||
)
|
||||
|
||||
@@ -322,8 +347,6 @@ def build_html(records: list[dict[str, Any]]) -> str:
|
||||
f"<div class='hero'>{hero}</div>"
|
||||
"<div class='meta'>"
|
||||
f"<h2>{html.escape(display_name)}</h2>"
|
||||
f"<p class='source'>{html.escape(record['source_file'])}</p>"
|
||||
f"<p class='fallback'>Fallback model: {html.escape(record['fallback_model'])}</p>"
|
||||
f"<div class='variants'>{''.join(preview_items)}</div>"
|
||||
"</div>"
|
||||
"</section>"
|
||||
@@ -393,59 +416,62 @@ def build_html(records: list[dict[str, Any]]) -> str:
|
||||
}}
|
||||
.stat span {{ display: block; color: var(--muted); font-size: 0.82rem; margin-bottom: 4px; }}
|
||||
.stat strong {{ font-size: 1.4rem; }}
|
||||
.grid {{ display: grid; gap: 18px; }}
|
||||
.card {{
|
||||
display: grid;
|
||||
grid-template-columns: 210px minmax(0, 1fr);
|
||||
gap: 18px;
|
||||
.grid {{
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
||||
gap: 14px;
|
||||
}}
|
||||
.card {{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 24px;
|
||||
border-radius: 20px;
|
||||
background: var(--card);
|
||||
box-shadow: var(--shadow);
|
||||
padding: 18px;
|
||||
padding: 14px;
|
||||
}}
|
||||
.hero {{
|
||||
min-height: 210px;
|
||||
border-radius: 20px;
|
||||
min-height: 150px;
|
||||
border-radius: 16px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
background: linear-gradient(160deg, rgba(157, 229, 123, 0.09), rgba(255, 255, 255, 0.02));
|
||||
display: grid;
|
||||
place-items: center;
|
||||
overflow: hidden;
|
||||
}}
|
||||
.hero img, .variant-preview img {{ width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }}
|
||||
.hero img, .variant-preview img {{ width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }}
|
||||
.hero-missing, .preview-missing {{
|
||||
color: var(--muted);
|
||||
font-size: 0.85rem;
|
||||
font-size: 0.78rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.12em;
|
||||
padding: 16px;
|
||||
padding: 12px;
|
||||
text-align: center;
|
||||
}}
|
||||
.meta h2 {{ margin: 2px 0 8px; font-size: 1.7rem; }}
|
||||
.source, .fallback {{ color: var(--muted); margin: 0 0 8px; }}
|
||||
.variants {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 16px; }}
|
||||
.meta h2 {{ margin: 0 0 6px; font-size: 1.35rem; }}
|
||||
.variants {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 10px; }}
|
||||
.variant {{
|
||||
border: 1px solid rgba(157, 229, 123, 0.14);
|
||||
border-radius: 18px;
|
||||
border-radius: 14px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
padding: 10px;
|
||||
padding: 8px;
|
||||
}}
|
||||
.variant-preview {{
|
||||
aspect-ratio: 1 / 1;
|
||||
border-radius: 14px;
|
||||
border-radius: 12px;
|
||||
background: rgba(0, 0, 0, 0.18);
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 8px;
|
||||
overflow: hidden;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
}}
|
||||
.variant-name {{ font-weight: 700; margin-bottom: 4px; }}
|
||||
.variant-model {{ color: var(--muted); font-size: 0.82rem; word-break: break-word; }}
|
||||
.footer {{ color: var(--muted); margin-top: 24px; font-size: 0.9rem; }}
|
||||
.variant-name {{ font-weight: 700; margin-bottom: 3px; font-size: 0.92rem; }}
|
||||
.footer {{ color: var(--muted); margin-top: 22px; font-size: 0.9rem; }}
|
||||
@media (max-width: 860px) {{
|
||||
.stats, .card {{ grid-template-columns: 1fr; }}
|
||||
.hero {{ min-height: 160px; }}
|
||||
.stats {{ grid-template-columns: 1fr; }}
|
||||
.grid {{ grid-template-columns: 1fr; }}
|
||||
.hero {{ min-height: 140px; }}
|
||||
}}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user