sphinx_gallery.scrapers¶
Scrapers for embedding images¶
Collect images that have been produced by code blocks.
The only scrapers we support are Matplotlib and Mayavi, others should live in modules that will support them (e.g., PyVista, Plotly).
Functions¶
-
sphinx_gallery.scrapers.
clean_modules
(gallery_conf, fname)[source]¶ Remove, unload, or reset modules after running each example.
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:
-
sphinx_gallery.scrapers.
figure_rst
(figure_list, sources_dir)[source]¶ Generate RST for a list of image filenames.
Depending on whether we have one or more figures, we use a single rst call to ‘image’ or a horizontal list.
Parameters: Returns: images_rst – rst code to embed the images in the document
Return type:
-
sphinx_gallery.scrapers.
matplotlib_scraper
(block, block_vars, gallery_conf, **kwargs)[source]¶ Scrape Matplotlib images.
Parameters: - block (tuple) – A tuple containing the (label, content, line_number) of the block.
- block_vars (dict) – Dict of block variables.
- gallery_conf (dict) – Contains the configuration of Sphinx-Gallery
- **kwargs (dict) – Additional keyword arguments to pass to
savefig()
, e.g.format='svg'
. Theformat
kwarg in particular is used to set the file extension of the output file (currently only ‘png’, ‘jpg’, and ‘svg’ are supported).
Returns: rst – The ReSTructuredText that will be rendered to HTML containing the images. This is often produced by
figure_rst()
.Return type:
-
sphinx_gallery.scrapers.
mayavi_scraper
(block, block_vars, gallery_conf)[source]¶ Scrape Mayavi images.
Parameters: Returns: rst – The ReSTructuredText that will be rendered to HTML containing the images. This is often produced by
figure_rst()
.Return type: