Finish the wonderland: System told truthfully, in eight tabs instead of ten
Claude-Session: https://claude.ai/code/session_01Ms2FbjQy31TVf3CEvQhGM8
This commit is contained in:
@@ -64,6 +64,8 @@ CATEGORY = re.compile(
|
||||
r'\{\s*page:\s*"([a-z-]+)",\s*label:\s*"([^"]+)",\s*icon:\s*"[^"]*",\s*tabs:\s*\[([^\]]*)\]\s*\}',
|
||||
re.S)
|
||||
TAB = re.compile(r'\{\s*page:\s*"([a-z-]+)",\s*label:\s*"([^"]+)"\s*\}')
|
||||
HIDDEN = re.compile(
|
||||
r'\{\s*page:\s*"([a-z-]+)",\s*label:\s*"([^"]+)",\s*category:\s*"([a-z-]+)"\s*\}')
|
||||
|
||||
|
||||
def categories() -> list[tuple[str, str, list[tuple[str, str]]]]:
|
||||
@@ -87,6 +89,33 @@ def categories() -> list[tuple[str, str, list[tuple[str, str]]]]:
|
||||
return found
|
||||
|
||||
|
||||
def hidden_leaves() -> list[tuple[str, str]]:
|
||||
"""Leaves that are routable but draw no tab, as (id, label).
|
||||
|
||||
The manual is the one: reference material rather than a control surface, so
|
||||
it is opened from About, a deep link, or a launcher command rather than
|
||||
found by scanning a tab strip. Which makes the command below the main way
|
||||
anybody reaches it, and dropping it because it has no tab would be exactly
|
||||
the wrong conclusion.
|
||||
|
||||
They live outside `categories` because the reader above requires each
|
||||
category to end `tabs: [...] }` and cross-checks every `page:` inside that
|
||||
array; a hidden leaf declared in there would break both.
|
||||
"""
|
||||
source = read(ROUTES)
|
||||
block = re.search(r"readonly property var hiddenLeaves: \[(.*?)\n \]", source, re.S)
|
||||
if not block:
|
||||
return []
|
||||
found = HIDDEN.findall(block.group(1))
|
||||
declared = len(re.findall(r'\bpage:\s*"', block.group(1)))
|
||||
if len(found) != declared:
|
||||
raise ParseError(
|
||||
f"read {len(found)} of the {declared} hidden leaves in "
|
||||
"SettingsRoutes.qml; that array no longer looks the way this "
|
||||
"reader expects")
|
||||
return [(page, label) for page, label, _category in found]
|
||||
|
||||
|
||||
def pages() -> list[tuple[str, str]]:
|
||||
"""The leaf pages, in sidebar order, as (id, label).
|
||||
|
||||
@@ -97,6 +126,7 @@ def pages() -> list[tuple[str, str]]:
|
||||
leaves: list[tuple[str, str]] = []
|
||||
for page, label, tabs in categories():
|
||||
leaves += tabs or [(page, label)]
|
||||
leaves += hidden_leaves()
|
||||
ids = [page for page, _label in leaves]
|
||||
duplicated = sorted({page for page in ids if ids.count(page) > 1})
|
||||
if duplicated:
|
||||
|
||||
Reference in New Issue
Block a user