sphinx_gallery.sorting#

Sorters for Sphinx-Gallery (sub)sections.

Sorting key functions for gallery subsection folders and section files.

Classes#

classsphinx_gallery.sorting.ExampleTitleSortKey(src_dir)[source]#

Sort examples in src_dir by example title.

Parameters:

src_dir (str) – The source directory.

classsphinx_gallery.sorting.ExplicitOrder(ordered_list)[source]#

Sorting key for all gallery subsections.

All subsections folders must be listed, otherwise an exception is raised.However, you can add ‘*’ as a placeholder to the list. All not-listedsubsection folders will be inserted at the given position and noexception is raised.

Parameters:

ordered_list (list, tuple, orgenerator) – Hold the paths of each galleries’ subsections.

Raises:

ValueError – Wrong input type or Subgallery path missing.

classsphinx_gallery.sorting.FileNameSortKey(src_dir)[source]#

Sort examples in src_dir by file name.

Parameters:

src_dir (str) – The source directory.

classsphinx_gallery.sorting.FileSizeSortKey(src_dir)[source]#

Sort examples in src_dir by file size.

Parameters:

src_dir (str) – The source directory.

classsphinx_gallery.sorting.FunctionSortKey(func,r=None)[source]#

Sort examples using a function passed through tosorted().

Parameters:
  • func (callable) – sorting key function,can only take one argument, i.e. lambda func = arg: arg[0] * arg[1]

  • r (str,None) – printable representation of object

classsphinx_gallery.sorting.NumberOfCodeLinesSortKey(src_dir)[source]#

Sort examples in src_dir by the number of code lines.

Parameters:

src_dir (str) – The source directory.