Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix basic/full tutorial order #250

Merged
merged 1 commit into from
Oct 16, 2023
Merged
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
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