-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Expand file tree
/
Copy pathgallery_order.py
More file actions
84 lines (71 loc) · 2.96 KB
/
gallery_order.py
File metadata and controls
84 lines (71 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""
Configuration for the order of gallery sections and examples.
Paths are relative to the conf.py file.
"""
from sphinx_gallery.sorting import ExplicitOrder
# Gallery sections shall be displayed in the following order.
# Non-matching sections are appended.
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']
class MplExplicitOrder(ExplicitOrder):
""" for use within the 'subsection_order' key"""
def __call__(self, item):
"""Return a string determining the sort order."""
if item in self.ordered_list:
return "{:04d}".format(self.ordered_list.index(item))
else:
# ensure not explicitly listed items come last.
return "zzz" + item
# Subsection order:
# Subsections are ordered by filename, unless they appear in the following
# lists in which case the list order determines the order within the section.
# Examples/tutorials that do not appear in a list will be appended.
list_all = [
# **Tutorials**
# introductory
"usage", "pyplot", "sample_plots", "images", "lifecycle", "customizing",
# intermediate
"artists", "legend_guide", "color_cycle", "gridspec",
"constrainedlayout_guide", "tight_layout_guide",
# advanced
# text
"text_intro", "text_props",
# colors
"colors",
# **Examples**
# color
"color_demo",
# pies
"pie_features", "pie_demo2",
]
explicit_subsection_order = [item + ".py" for item in list_all]
class MplExplicitSubOrder(object):
""" for use within the 'within_subsection_order' key """
def __init__(self, src_dir):
self.src_dir = src_dir # src_dir is unused here
self.ordered_list = explicit_subsection_order
def __call__(self, item):
"""Return a string determining the sort order."""
if item in self.ordered_list:
return "{:04d}".format(self.ordered_list.index(item))
else:
# ensure not explicitly listed items come last.
return "zzz" + item
# Provide the above classes for use in conf.py
sectionorder = MplExplicitOrder(explicit_order_folders)
subsectionorder = MplExplicitSubOrder