From 32cc1ce4fa42270fee774d815b43c0cf57129c5b Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Thu, 5 Nov 2026 19:46:22 +0100 Subject: [PATCH] fix: render a single tab without a tab bar 142 tab bars held one tab, most of them "On the device" under a heading saying so. One item now stands alone, led by its label unless it names the place the text around already gives. The network route drops "Run the command on the computer" under the heading "From your computer", which keeps RetroPie in its word budget. --- scripts/generate_site.py | 2 +- scripts/siteguides.py | 6 ++++++ scripts/sitemarkup.py | 11 ++++++++++- tests/test_site_components.py | 16 ++++++++++++++++ tests/test_site_emulators.py | 4 +++- tests/test_site_entry.py | 4 +++- 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/scripts/generate_site.py b/scripts/generate_site.py index e9d0dec0e..9b23dc852 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -4202,7 +4202,7 @@ def _setup_routes(name: str, display: str, page_link: bool = False) -> list[str] # lines are on the get/ page, the one the command is shared from. tabs = ("windows",) if page_link else ("windows", "macos", "linux") computer += [ - "Needs the device on your network. Run the command on the computer.", + "Needs the device on your network.", "", *terminal_tabs(tabs, args, how=how), *([f"[Mac or Linux](../{get_page_link(name)}#from-your-computer)", ""] diff --git a/scripts/siteguides.py b/scripts/siteguides.py index 0436ca768..786653620 100644 --- a/scripts/siteguides.py +++ b/scripts/siteguides.py @@ -454,6 +454,10 @@ def fence(shell: str, command: str, indent: str = "") -> list[str]: return [f'{indent}```{shell} title="{FENCE_TITLES[shell]}"', f"{indent}{command}", f"{indent}```"] +# Terminals named by where the command runs, not by the system it runs on. +PLACES = ("device", "server") + + def terminal_tabs( tabs: tuple[str, ...], args: dict[str, str], indent: str = "", steps: bool = True, how: dict[str, str] | None = None, @@ -465,6 +469,8 @@ def terminal_tabs( items = [] for key in tabs: label, shared, shell = TERMINALS[key] + if len(tabs) == 1 and key in PLACES: + label = "" # one place, which the text around already names text = (how or {}).get(key) or shared body = [text, ""] if steps else [] items.append((label, body + fence(shell, install_command(shell, args.get(key, ""))))) diff --git a/scripts/sitemarkup.py b/scripts/sitemarkup.py index cbd995606..e440d5cc5 100644 --- a/scripts/sitemarkup.py +++ b/scripts/sitemarkup.py @@ -139,8 +139,17 @@ def details(kind: str, title: str, body: list[str], indent: str = "", opened: bo def tabs(items: list[tuple[str, list[str]]], indent: str = "", sync: str = "os") -> list[str]: """Content tabs. Tabs that share a label share the reader's choice - across pages.""" + across pages. + + One item is no choice: 142 bars offered a single tab, most of them + "On the device" under a heading that says so. Its body stands alone, + led by its label when it has one: the RetroPie card is read from Linux + only, and the label is where the page said so.""" lines: list[str] = [] + if len(items) == 1: + label, body = items[0] + lead = [f"{indent}**{label}**", ""] if label else [] + return [*lead, *_indented(_trim(body), indent), ""] if _engine == "mkdocs": for label, body in items: lines += [f'{indent}=== "{label}"', "", *_indented(_trim(body), indent + " "), ""] diff --git a/tests/test_site_components.py b/tests/test_site_components.py index 20e06fd29..17fe94afb 100644 --- a/tests/test_site_components.py +++ b/tests/test_site_components.py @@ -334,6 +334,22 @@ class NoLevelBadgeOnATabRoot(unittest.TestCase): self.assertNotIn('class="rb-level ', _title_through_heading(_built(page))) +class OneTabIsNoTabBar(unittest.TestCase): + """142 tab bars held one tab, most of them "On the device" right under + the heading "On the device".""" + + def test_a_single_item_stands_alone(self): + import sitemarkup + import siteguides + + self.assertEqual(sitemarkup.tabs([("Linux", ["run it"])]), ["**Linux**", "", "run it", ""]) + self.assertEqual(sitemarkup.tabs([("", ["run it"])]), ["run it", ""]) + self.assertIn('', sitemarkup.tabs([("A", ["a"]), ("B", ["b"])])) + device = "\n".join(siteguides.terminal_tabs(("device",), {})) + self.assertNotIn("")] self.assertRegex(install, r"With [^:]+: the installer finds") - self.assertEqual(set(re.findall(r'', install)), {"On the device"}) + # One place to run it, so no tab bar (one tab offers no choice). + self.assertNotIn("