From 87b928205c1bed2aecad546a05003c6935a60967 Mon Sep 17 00:00:00 2001 From: Harish Mohan Raj Date: Wed, 18 Dec 2024 11:56:36 +0000 Subject: [PATCH] Sort the API reference navigation --- website/process_api_reference.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/website/process_api_reference.py b/website/process_api_reference.py index 689f2a72ea..662a0ec5d2 100644 --- a/website/process_api_reference.py +++ b/website/process_api_reference.py @@ -149,15 +149,20 @@ def create_nav_structure(paths: List[str], parent_groups: List[str] = None) -> L subpath = "/".join(parts[1:]) groups.setdefault(group, []).append(subpath) - result = [ + # Sort directories and create their structures + sorted_groups = [ { "group": ".".join(parent_groups + [group]) if parent_groups else group, "pages": create_nav_structure(subpaths, parent_groups + [group]), } - for group, subpaths in groups.items() - ] + pages + for group, subpaths in sorted(groups.items()) + ] - return result + # Sort pages + sorted_pages = sorted(pages) + + # Return directories first, then files + return sorted_groups + sorted_pages def update_nav(mint_json_path: Path, new_nav_pages: List[Any]) -> None: