From 742bf7141d27e606becbe7672e74bf93947fe152 Mon Sep 17 00:00:00 2001 From: Roman Zlobin Date: Mon, 16 Oct 2023 23:34:55 +0300 Subject: [PATCH] account for `_full` postfix when sorting tutorials (#250) --- docs/source/utils/generate_tutorials.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/source/utils/generate_tutorials.py b/docs/source/utils/generate_tutorials.py index 1f74ca1a4..5e8e0e333 100644 --- a/docs/source/utils/generate_tutorials.py +++ b/docs/source/utils/generate_tutorials.py @@ -68,7 +68,16 @@ def sort_tutorial_file_tree(files: Set[Path]) -> List[Path]: :param files: Files list to sort. """ tutorials = {file for file in files if file.stem.split("_")[0].isdigit()} - return sorted(tutorials, key=lambda file: int(file.stem.split("_")[0])) + sorted(files - tutorials) + + def sort_key(tutorial_file_name: Path) -> float: + tutorial_number = float(tutorial_file_name.stem.split("_")[0]) + + # full tutorials should go after tutorials with the same number + if tutorial_file_name.stem.endswith("_full"): + return tutorial_number + 0.5 + return tutorial_number + + return sorted(tutorials, key=sort_key) + sorted(files - tutorials) def iterate_tutorials_dir_generating_links(source: Path, dest: Path, base: str) -> List[Path]: