Skip to content

Commit

Permalink
docs: Order the example sections manually (#1152)
Browse files Browse the repository at this point in the history
Fix part of #1019

✅ We can set an explicit order for the subsections (the categories of
examples):
```python
# list of examples in explicit order
subsections_order = [
    "../examples/getting_started",
    "../examples/model_evaluation",
]

sphinx_gallery_conf = {
    # ...
    "subsection_order": ExplicitOrder(subsections_order),  # sorting gallery subsections,
    # ...
}
```

❌ Inside a subsection, we can sort the examples by example title:
```python
sphinx_gallery_conf = {
    # ...
    "within_subsection_order": "ExampleTitleSortKey",
    # ...
}
```
but I can't set an explicit order myself for the examples in
`getting_started` and in `model_evaluation`.
This will be for another PR.
  • Loading branch information
sylvaincom authored Jan 20, 2025
1 parent a3edbc3 commit 5014158
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,12 @@
]

# list of examples in explicit order
examples_ordered = [
subsections_order = [
"../examples/getting_started",
"../examples/getting_started/plot_quick_start",
"../examples/getting_started/plot_skore_product_tour",
"../examples/getting_started/plot_working_with_projects",
"../examples/getting_started/plot_tracking_items",
"../examples/model_evaluation",
"../examples/model_evaluation/plot_train_test_split",
"../examples/model_evaluation/plot_cross_validate",
]


# Augment the dpi of matplotlib figures in Sphinx examples
# https://sphinx-gallery.github.io/stable/advanced.html#resetting-before-each-example
def reset_mpl(gallery_conf, fname):
import matplotlib
Expand All @@ -84,8 +78,9 @@ def reset_mpl(gallery_conf, fname):
sphinx_gallery_conf = {
"examples_dirs": "../examples", # path to example scripts
"gallery_dirs": "auto_examples", # path to gallery generated output
"subsection_order": ExplicitOrder(examples_ordered),
"within_subsection_order": "FileNameSortKey", # See https://sphinx-gallery.github.io/stable/configuration.html#sorting-gallery-examples for alternatives
"subsection_order": ExplicitOrder(subsections_order), # sorting gallery subsections,
# see https://sphinx-gallery.github.io/stable/configuration.html#sub-gallery-order
"within_subsection_order": "ExampleTitleSortKey", # See https://sphinx-gallery.github.io/stable/configuration.html#sorting-gallery-examples for alternatives
"show_memory": False,
"write_computation_times": False,
"reference_url": {
Expand Down

0 comments on commit 5014158

Please sign in to comment.