Skip to content

Commit

Permalink
DOC UPDATE: sphinx_gallery 0.16
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbrodbeck committed May 11, 2024
1 parent ad80575 commit 3030ae5
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import eelbrain.plot._brain_object # make sure that Brain is available
import eelbrain
import mne
from sphinx_gallery.sorting import ExplicitOrder, _SortKey


# docutils 0.14
Expand Down Expand Up @@ -75,26 +76,7 @@ def use_pyplot(gallery_conf, fname):
eelbrain.configure(frame=False)


class NameOrder:
"""Specify sphinx-gallery example order as file tree"""

def __init__(self, order):
self._order = order

def __repr__(self):
return f"{self.__class__.__name__}({self._order})"

def __call__(self, item):
path = Path(item)
if isinstance(self._order, dict):
return NameOrder(self._order[path.name])
return self._order.index(path.name)

def section_order(self):
return NameOrder(list(self._order))


example_order = NameOrder({
example_order = {
'examples': [],
'datasets': [
'intro.py',
Expand Down Expand Up @@ -127,13 +109,23 @@ def section_order(self):
'partitions.py',
'epoch_impulse.py',
],
})
}


class NameOrder(_SortKey):
"""Specify sphinx-gallery example order as file tree"""

def __call__(self, item):
path = Path(item)
section = path.parent.name
i = list(example_order).index(section) * 100
return i + example_order[section].index(path.name)


sphinx_gallery_conf = {
'examples_dirs': '../examples', # path to example scripts
'subsection_order': example_order.section_order(),
'within_subsection_order': example_order,
'subsection_order': ExplicitOrder(example_order.keys()),
'within_subsection_order': NameOrder,
'gallery_dirs': 'auto_examples', # path where to save gallery generated examples
'filename_pattern': rf'{os.sep}\w',
'default_thumb_file': Path(__file__).parent / 'images' / 'eelbrain.png',
Expand Down

0 comments on commit 3030ae5

Please sign in to comment.