Skip to content
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
75 changes: 47 additions & 28 deletions doc/sphinxext/gallery_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,52 @@
from sphinx_gallery.sorting import ExplicitOrder

# Gallery sections shall be displayed in the following order.
# Non-matching sections are inserted at UNSORTED
explicit_order_folders = [
'../examples/lines_bars_and_markers',
'../examples/images_contours_and_fields',
'../examples/subplots_axes_and_figures',
'../examples/statistics',
'../examples/pie_and_polar_charts',
'../examples/text_labels_and_annotations',
'../examples/pyplots',
'../examples/color',
'../examples/shapes_and_collections',
'../examples/style_sheets',
'../examples/axes_grid1',
'../examples/axisartist',
'../examples/showcase',
'../tutorials/introductory',
'../tutorials/intermediate',
'../tutorials/advanced',
'../plot_types/basic',
'../plot_types/arrays',
'../plot_types/stats',
'../plot_types/unstructured',
'../plot_types/3D',
'UNSORTED',
'../examples/userdemo',
'../tutorials/provisional',
]
# Non-matching sections are inserted at the unsorted position

UNSORTED = "unsorted"

examples_order = [
'../examples/lines_bars_and_markers',
'../examples/images_contours_and_fields',
'../examples/subplots_axes_and_figures',
'../examples/statistics',
'../examples/pie_and_polar_charts',
'../examples/text_labels_and_annotations',
'../examples/pyplots',
'../examples/color',
'../examples/shapes_and_collections',
'../examples/style_sheets',
'../examples/axes_grid1',
'../examples/axisartist',
'../examples/showcase',
UNSORTED,
'../examples/userdemo',
]

tutorials_order = [
'../tutorials/introductory',
'../tutorials/intermediate',
'../tutorials/advanced',
UNSORTED,
'../tutorials/provisional'
]

plot_types_order = [
'../plot_types/basic',
'../plot_types/arrays',
'../plot_types/stats',
'../plot_types/unstructured',
'../plot_types/3D',
UNSORTED
]

folder_lists = [examples_order, tutorials_order, plot_types_order]

explicit_order_folders = [fd for folders in folder_lists
for fd in folders[:folders.index(UNSORTED)]]
explicit_order_folders.append(UNSORTED)
explicit_order_folders.extend([fd for folders in folder_lists
for fd in folders[folders.index(UNSORTED):]])


class MplExplicitOrder(ExplicitOrder):
Expand All @@ -42,7 +61,7 @@ def __call__(self, item):
if item in self.ordered_list:
return f"{self.ordered_list.index(item):04d}"
else:
return f"{self.ordered_list.index('UNSORTED'):04d}{item}"
return f"{self.ordered_list.index(UNSORTED):04d}{item}"

# Subsection order:
# Subsections are ordered by filename, unless they appear in the following
Expand Down