sphinx_gallery.sorting¶
Sorters for Sphinx-Gallery (sub)sections¶
Sorting key functions for gallery subsection folders and section files.
Functions¶
-
sphinx_gallery.sorting.
extract_intro_and_title
(filename, docstring)¶ Extract the first paragraph of module-level docstring. max:95 char
-
sphinx_gallery.sorting.
split_code_and_text_blocks
(source_file)¶ Return list with source file separated into code and text blocks.
Returns: - file_conf (dict) –
File-specific settings given in comments as:
# sphinx_gallery_<name> = <value>
- blocks (list of (label, content)) – List where each element is a tuple with the label (‘text’ or ‘code’), and content string of block.
- file_conf (dict) –
File-specific settings given in comments as:
Classes¶
-
class
sphinx_gallery.sorting.
ExampleTitleSortKey
(src_dir)¶ Sort examples in src_dir by example title.
Parameters: src_dir (str) – The source directory.
-
class
sphinx_gallery.sorting.
ExplicitOrder
(ordered_list)¶ Sorting key for all gallery subsections.
This requires all folders to be listed otherwise an exception is raised.
Parameters: ordered_list (list, tuple, types.GeneratorType) – Hold the paths of each galleries’ subsections. Raises: ValueError
– Wrong input type or Subgallery path missing.
-
class
sphinx_gallery.sorting.
FileNameSortKey
(src_dir)¶ Sort examples in src_dir by file size.
Parameters: src_dir (str) – The source directory.
-
class
sphinx_gallery.sorting.
FileSizeSortKey
(src_dir)¶ Sort examples in src_dir by file size.
Parameters: src_dir (str) – The source directory.
-
class
sphinx_gallery.sorting.
NumberOfCodeLinesSortKey
(src_dir)¶ Sort examples in src_dir by the number of code lines.
Parameters: src_dir (str) – The source directory.