sphinx_gallery.scrapers#

Scrapers for embedding images.

Collect images that have been produced by code blocks.

The only scraper we natively support is Matplotlib, others should live in modules that will support them (e.g., PyVista, Plotly). Scraped images are injected as rst image-sg directives into the .rst file generated for each example script.

Functions#

sphinx_gallery.scrapers.clean_modules(gallery_conf, fname, when)[source]#

Remove, unload, or reset modules.

After a script is executed it can load a variety of settings that one does not want to influence in other examples in the gallery.

Parameters:
  • gallery_conf (dict) – The gallery configuration.

  • fname (str or None) – The example being run. Will be None when this is called entering a directory of examples to be built.

  • when (str) –

    Whether this module is run before or after examples.

    This parameter is only forwarded when the callables accept 3 parameters.

Classes#

class sphinx_gallery.scrapers.ImagePathIterator(image_path)[source]#

Iterate over image paths for a given example.

Parameters:

image_path (str) – The template image path.

next()[source]#

Return the next image path, with numbering starting at 1.