4
4
"""
5
5
6
6
from sphinx_gallery .sorting import ExplicitOrder
7
+ import os
8
+
9
+
10
+ # Utility functions
11
+ def get_ordering (dir ):
12
+ """Read gallery_order.txt in dir and return content of the file as a List"""
13
+ file_path = os .path .join (dir , 'gallery_order.txt' )
14
+ f = open (file_path , "r" )
15
+ lines = [line .replace ('\n ' , '' ) for line in f .readlines ()]
16
+ ordered_list = []
17
+ for line in lines :
18
+ if line == "unsorted" :
19
+ ordered_list .append (UNSORTED )
20
+ else :
21
+ ordered_list .append (line )
22
+
23
+ return ordered_list
24
+
25
+
26
+ def list_directory (parent_dir ):
27
+ """Return list of sub directories at a directory"""
28
+ root , dirs , files = next (os .walk (parent_dir ))
29
+ return [os .path .join (root , dir ) for dir in dirs ]
7
30
8
31
# Gallery sections shall be displayed in the following order.
9
32
# Non-matching sections are inserted at the unsorted position
10
33
11
34
UNSORTED = "unsorted"
12
35
36
+
13
37
examples_order = [
14
38
'../galleries/examples/lines_bars_and_markers' ,
15
39
'../galleries/examples/images_contours_and_fields' ,
36
60
'../galleries/tutorials/provisional'
37
61
]
38
62
39
- plot_types_order = [
40
- '../galleries/plot_types/basic' ,
41
- '../galleries/plot_types/stats' ,
42
- '../galleries/plot_types/arrays' ,
43
- '../galleries/plot_types/unstructured' ,
44
- '../galleries/plot_types/3D' ,
45
- UNSORTED
46
- ]
63
+ # plot_types_order = [
64
+ # '../galleries/plot_types/basic',
65
+ # '../galleries/plot_types/stats',
66
+ # '../galleries/plot_types/arrays',
67
+ # '../galleries/plot_types/unstructured',
68
+ # '../galleries/plot_types/3D',
69
+ # UNSORTED
70
+ # ]
47
71
48
- folder_lists = [examples_order , tutorials_order , plot_types_order ]
72
+ plot_types_directory = "../galleries/plot_types/"
73
+ plot_types_order = get_ordering (plot_types_directory )
49
74
75
+
76
+ folder_lists = [examples_order , tutorials_order , plot_types_order ]
50
77
explicit_order_folders = [fd for folders in folder_lists
51
78
for fd in folders [:folders .index (UNSORTED )]]
52
79
explicit_order_folders .append (UNSORTED )
@@ -89,19 +116,30 @@ def __call__(self, item):
89
116
90
117
# **Plot Types
91
118
# Basic
92
- "plot" , "scatter_plot" , "bar" , "stem" , "step" , "fill_between" ,
119
+ # "plot", "scatter_plot", "bar", "stem", "step", "fill_between",
93
120
# Arrays
94
- "imshow" , "pcolormesh" , "contour" , "contourf" ,
95
- "barbs" , "quiver" , "streamplot" ,
121
+ # "imshow", "pcolormesh", "contour", "contourf",
122
+ # "barbs", "quiver", "streamplot",
96
123
# Stats
97
- "hist_plot" , "boxplot_plot" , "errorbar_plot" , "violin" ,
98
- "eventplot" , "hist2d" , "hexbin" , "pie" ,
124
+ # "hist_plot", "boxplot_plot", "errorbar_plot", "violin",
125
+ # "eventplot", "hist2d", "hexbin", "pie",
99
126
# Unstructured
100
- "tricontour" , "tricontourf" , "tripcolor" , "triplot" ,
127
+ # "tricontour", "tricontourf", "tripcolor", "triplot",
101
128
# Spines
102
129
"spines" , "spine_placement_demo" , "spines_dropped" ,
103
130
"multiple_yaxis_with_spines" , "centered_spines_with_arrows" ,
104
131
]
132
+
133
+
134
+ for dir in list_directory (plot_types_directory ):
135
+ try :
136
+ ordered_subdirs = get_ordering (dir )
137
+ list_all .extend (ordered_subdirs )
138
+ except FileNotFoundError :
139
+ # Fallback to ordering already defined in list_all
140
+ pass
141
+
142
+
105
143
explicit_subsection_order = [item + ".py" for item in list_all ]
106
144
107
145
0 commit comments