myst_sphinx_gallery.directives#
Sphinx directives to generate galleries.
Functions
|
Create a card node for the grid. |
|
Create a title node for the card. |
|
Create a container node for a design component. |
|
Create a container node for the grid. |
|
Create a title node for the section. |
|
Ensure that the gallery config is set. |
|
Format the option for the directive. |
|
Validate the number of columns (out of 12) a grid row will have. |
Classes
|
Directive to create a |
|
A wrapper of the sphinx-design card directive to add gallery features. |
|
An abstract class for the gallery directives. |
|
Directive to create a |
|
Directive to create a referenced gallery using |
|
A container node for a card column. |
- class myst_sphinx_gallery.directives.GalleryABC(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]#
An abstract class for the gallery directives.
- create_cards_for_row_node(entry_files: str, row_node: Node, save_thumbnail: bool) Node[source]#
Create the cards for the row node.
- parse_file_gallery_config(file_path: str) GalleryConfig[source]#
Parse the gallery config for give file.
- class myst_sphinx_gallery.directives.RefGalleryDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]#
Directive to create a referenced gallery using
ref-gallerydirective.This gallery will not create toctree entries for the examples. The examples in this gallery are all referenced from other galleries.
- option_spec = {'tooltip': <function flag>}#
Mapping of option names to validator functions.
- has_content = True#
May the directive have content?
- class myst_sphinx_gallery.directives.BaseGallery(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]#
Directive to create a
base-gallerywith a toctree-like structure.- option_spec = {'caption': <function unchanged>, 'tooltip': <function flag>}#
Mapping of option names to validator functions.
- has_content = True#
May the directive have content?
- class myst_sphinx_gallery.directives.GalleryDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]#
Directive to create a
gallerywith a toctree-like structure.Hint
The items in this gallery are the files that contain the
base-gallerydirectives.The title of each file of items will be used as the section title in the gallery.
The
*wildcard can be used for matching multiple files.
- option_spec = {'caption': <function unchanged>, 'tooltip': <function flag>}#
Mapping of option names to validator functions.
- has_content = True#
May the directive have content?
- myst_sphinx_gallery.directives.ensure_config(config: GalleryConfig | GalleryThumbnailConfig | dict | None) GalleryConfig[source]#
Ensure that the gallery config is set.
- myst_sphinx_gallery.directives.format_option(option: dict) dict[source]#
Format the option for the directive.
- myst_sphinx_gallery.directives.row_columns_option(argument: str | None) list[str][source]#
Validate the number of columns (out of 12) a grid row will have.
One or four integers (for “xs sm md lg”) between 1 and 12 (or ‘auto’).
- class myst_sphinx_gallery.directives.CardDirectiveWrapper(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]#
A wrapper of the sphinx-design card directive to add gallery features.
Modifications include:
Adding myst-sphinx-gallery classes to the card.
Adding loading=”lazy” to the image tags.
Removing some unnecessary components.
- myst_sphinx_gallery.directives.create_grid_node(grid: Grid, sphinx_directive: SphinxDirective | None = None) tuple[Node, Node][source]#
Create a container node for the grid.
- myst_sphinx_gallery.directives.create_card_node(arguments: list, options: dict, sphinx_directive: SphinxDirective) Node[source]#
Create a card node for the grid.
- myst_sphinx_gallery.directives.create_title_node(title: str) Node[source]#
Create a title node for the section.
- myst_sphinx_gallery.directives.create_card_title_node(title: str, options: dict | None = None, sphinx_directive: SphinxDirective | None = None) Node[source]#
Create a title node for the card.