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