myst_sphinx_gallery.grid#

Patterns for the myst-sphinx-gallery extension.

Functions

param_to_str(parameter)

Format the grid or card parameters.

Classes

Grid([outline, reverse, class_container, ...])

A class to create a grid pattern by given parameters.

GridItemCard([width, text_align, shadow, ...])

A class to create a grid item card pattern by given parameters.

TocTree([pattern])

A class to create a table of content for the gallery images.

class myst_sphinx_gallery.grid.TocTree(pattern: str | None = None)[source]#

A class to create a table of content for the gallery images.

add_item(item: str) None[source]#

Add an item to the table of content.

property pattern: str#

Return the table of content pattern.

parse_item(file_path: Path, ref_dir: Path) str[source]#

Parse the item for the table of content from the file path.

Parameters:
  • file_path (Path) – The file path of the item.

  • ref_dir (Path) – The reference directory for the item.

copy() TocTree[source]#

Return a new instance of the TocTree class.

Note

The new instance will only have the same options, but no items.

class myst_sphinx_gallery.grid.Grid(outline: bool | None = None, reverse: bool | None = None, class_container: str | list[str] | None = None, class_row: str | list[str] | None = None)[source]#

A class to create a grid pattern by given parameters.

Detailed explanation of the parameters can be found in the grid options.

outline: bool | None = None#

Create a border around the grid.

reverse: bool | None = None#

Reverse the order of the grid items.

class_container: str | list[str] | None = None#

Additional CSS classes for the grid container element.

class_row: str | list[str] | None = None#

Additional CSS classes for the grid row element.

add_option(option: str, value: object) None[source]#

Add an option to the grid item card pattern.

add_class_option(option: str, value: str) None[source]#

Add class option to the grid pattern.

add_item(item: GridItemCard | str) None[source]#

Add an item to the grid pattern.

property pattern: str#

Return the grid item card pattern string.

This property is a alias for the to_string method.

to_string() str[source]#

Return the grid pattern string.

copy() Grid[source]#

Return a new instance of Grid with same options.

Note

The new instance will only have the same options, but no items.

class myst_sphinx_gallery.grid.GridItemCard(width: Literal['25%', '50%', '75%', '100%', 'auto'] | None = None, text_align: Literal['left', 'right', 'center', 'justify'] = 'center', shadow: Literal['none', 'sm', 'md', 'lg'] = 'md', border: Literal[0, 1, 2, 3, 4, 5] | tuple[int, int, int, int] = 0, rounded: Literal[0, 1, 2, 3, 'circle', 'pill'] = 2, class_card: str | list[str] | None = None, class_title: str | list[str] | None = None, class_img_top: str | list[str] | None = None, class_header: str | list[str] | None = None, class_body: str | list[str] | None = None, class_footer: str | list[str] | None = None)[source]#

A class to create a grid item card pattern by given parameters.

Detailed explanation of the parameters can be found in the card options. and grid item card.

width: Literal['25%', '50%', '75%', '100%', 'auto'] | None = None#

Additional CSS classes for the grid row element.

text_align: Literal['left', 'right', 'center', 'justify'] = 'center'#

left, right, center or justify

Type:

Default horizontal text alignment

shadow: Literal['none', 'sm', 'md', 'lg'] = 'md'#

none, sm (default), md, lg.

Type:

The size of the shadow below the card

border: Literal[0, 1, 2, 3, 4, 5] | tuple[int, int, int, int] = 0#

0, 1, 2, 3, 4, 5 or a tuple of four integers for (top bottom left right).

Type:

The border width of the card

rounded: Literal[0, 1, 2, 3, 'circle', 'pill'] = 2#

0, 1, 2, 3, “circle”, “pill”.

Type:

The border radius of the card

class_card: str | list[str] | None = None#

Additional CSS classes for the card container element.

class_title: str | list[str] | None = None#

Additional CSS classes for the title element.

class_img_top: str | list[str] | None = None#

Additional CSS classes for the top image

class_header: str | list[str] | None = None#

Additional CSS classes for the card image element.

class_body: str | list[str] | None = None#

Additional CSS classes for the body element.

Additional CSS classes for the footer element.

add_option(option: str, value: object) None[source]#

Add an option to the grid item card pattern.

add_class_option(option: str, value: str) None[source]#

Add class option to the grid item card pattern.

add_item(item: str) None[source]#

Add an item to the grid item card pattern.

property pattern: str#

Return the grid item card pattern string.

This property is a alias for the to_string method.

to_string() str[source]#

Return the grid item card pattern string.

format(target_ref: str, img_path: str) str[source]#

Format grid item card pattern with target reference and image path.

copy() GridItemCard[source]#

Return a new instance of GridItemCard with same options.

Note

The new instance will only have the same options, but no items.

myst_sphinx_gallery.grid.param_to_str(parameter: object) str[source]#

Format the grid or card parameters.