Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions scripts/generate_wallet_gateway_openrpc_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,16 @@ def update_docs_navigation(
navigation = docs.get("navigation")
if not isinstance(navigation, dict):
raise ValueError(f"docs.json navigation must be an object: {docs_json_path}")
dropdowns = navigation.get("dropdowns")
if not isinstance(dropdowns, list):
raise ValueError(f"docs.json navigation.dropdowns must be a list: {docs_json_path}")
dropdown = next((item for item in dropdowns if isinstance(item, dict) and item.get("dropdown") == dropdown_label), None)
if dropdown is None:
raise ValueError(f"Dropdown not found in docs.json: {dropdown_label}")
pages = dropdown.get("pages")
products = navigation.get("products")
if not isinstance(products, list):
raise ValueError(f"docs.json navigation.products must be a list: {docs_json_path}")
nav_root = next((item for item in products if isinstance(item, dict) and item.get("product") == dropdown_label), None)
if nav_root is None:
raise ValueError(f"Product not found in docs.json: {dropdown_label}")

pages = nav_root.get("pages")
if not isinstance(pages, list):
raise ValueError(f"Dropdown does not expose a pages list: {dropdown_label}")
raise ValueError(f"Product does not expose a pages list: {dropdown_label}")

refs = {overview_page_ref(output_dir, docs_json_path), docs_json_page_ref(output_dir / "operations" / "details.mdx", docs_json_path)}
refs.update(spec_page_ref(output_dir, docs_json_path, spec["spec_id"]) for spec in spec_entries)
Expand Down Expand Up @@ -310,7 +311,7 @@ def update_docs_navigation(
break
for offset, wallet_group in enumerate(wallet_groups):
pruned_pages.insert(min(insert_at + offset, len(pruned_pages)), wallet_group)
dropdown["pages"] = pruned_pages
nav_root["pages"] = pruned_pages
docs_json_path.write_text(json.dumps(docs, indent=2) + "\n", encoding="utf-8")
print(f"Updated docs navigation: {docs_json_path}")

Expand Down
7 changes: 3 additions & 4 deletions tests/test_wallet_kernel_nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def test_openrpc_nav_uses_wallet_gateway_section_shape(tmp_path: Path) -> None:
json.dumps(
{
"navigation": {
"dropdowns": [
"products": [
{
"dropdown": "API Reference",
"product": "API Reference",
"pages": [
{"group": "TypeScript", "pages": []},
{"group": "Wallet Kernel SDK", "pages": ["old-wallet"]},
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_openrpc_nav_uses_wallet_gateway_section_shape(tmp_path: Path) -> None:
],
)
docs = json.loads(docs_json.read_text(encoding="utf-8"))
pages = docs["navigation"]["dropdowns"][0]["pages"]
pages = docs["navigation"]["products"][0]["pages"]

assert pages == [
{"group": "TypeScript", "pages": []},
Expand Down Expand Up @@ -127,7 +127,6 @@ def test_openrpc_nav_uses_wallet_gateway_section_shape(tmp_path: Path) -> None:
{"group": "Splice APIs", "pages": []},
]


def test_openrpc_nav_group_helper_omits_redundant_spec_page_child(tmp_path: Path) -> None:
generated_reference_nav = load_script("generated_reference_nav")
docs_json = tmp_path / "docs-main" / "docs.json"
Expand Down