From 95dab275047669d9956d55e46a66acabec5b48d6 Mon Sep 17 00:00:00 2001 From: hannah Date: Thu, 19 Jan 2023 00:50:32 -0500 Subject: [PATCH] seperate out folder orderings Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> --- doc/sphinxext/gallery_order.py | 75 +++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/doc/sphinxext/gallery_order.py b/doc/sphinxext/gallery_order.py index 82c721f3c220..f0768d4df77f 100644 --- a/doc/sphinxext/gallery_order.py +++ b/doc/sphinxext/gallery_order.py @@ -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): @@ -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