mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 13:33:24 -05:00
fix: print platform detail lists as plain text
This commit is contained in:
1 parent
f033449766
commit
20937e688b
2 files changed
+27
-4
No files matched your search
@@ -2145,16 +2145,23 @@ def _render_platform_details(profile: dict) -> list[str]:
|
||||
if isinstance(pv, dict):
|
||||
lines.append(f" **{pk}:**")
|
||||
for sk, sv in pv.items():
|
||||
lines.append(f" - {sk}: {sv}")
|
||||
elif isinstance(pv, list):
|
||||
lines.append(f" **{pk}:** {', '.join(str(x) for x in pv)}")
|
||||
lines.append(f" - {sk}: {_plain_value(sv)}")
|
||||
else:
|
||||
lines.append(f" **{pk}:** {pv}")
|
||||
lines.append(f" **{pk}:** {_plain_value(pv)}")
|
||||
lines.append("")
|
||||
|
||||
return lines
|
||||
|
||||
|
||||
def _plain_value(value: object) -> str:
|
||||
"""A scalar or a list of scalars as a reader writes it, not as Python does."""
|
||||
if isinstance(value, bool):
|
||||
return "yes" if value else "no"
|
||||
if isinstance(value, (list, tuple)):
|
||||
return ", ".join(_plain_value(item) for item in value)
|
||||
return _escape_tags(str(value))
|
||||
|
||||
|
||||
def _render_structured_blocks(profile: dict) -> list[str]:
|
||||
"""Every remaining structured field, as a collapsible section."""
|
||||
lines: list[str] = []
|
||||
|
||||
@@ -73,6 +73,22 @@ class WikiSourceHeadings(unittest.TestCase):
|
||||
self.assertEqual(offenders, [])
|
||||
|
||||
|
||||
class PlatformDetails(unittest.TestCase):
|
||||
def test_lists_and_flags_read_as_prose(self):
|
||||
import generate_site
|
||||
|
||||
lines = generate_site._render_platform_details(
|
||||
{"platform_details": {"megacd": {
|
||||
"extensions_tried": [".bin", ".zip"],
|
||||
"hle_available": False,
|
||||
"root": "<system_dir>/x",
|
||||
}}}
|
||||
)
|
||||
self.assertIn(" - extensions_tried: .bin, .zip", lines)
|
||||
self.assertIn(" - hle_available: no", lines)
|
||||
self.assertIn(" - root: <system_dir>/x", lines)
|
||||
|
||||
|
||||
class RenderedSiteValidation(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.temp = tempfile.TemporaryDirectory(dir=TMP_ROOT)
|
||||
|
||||
Reference in new issue
Block a user