Skip to content

Commit

Permalink
account for _full postfix when sorting tutorials (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
RLKRo authored Oct 16, 2023
1 parent 8c79188 commit 742bf71
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/source/utils/generate_tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit 742bf71

Please sign in to comment.