Source code for

from glob import glob
import shutil
import os
from sphinx_gallery.scrapers import figure_rst
[docs]class PNGScraper(object): def __init__(self): self.seen = set()
[docs] def __repr__(self): return 'PNGScraper'
[docs] def __call__(self, block, block_vars, gallery_conf): # Find all PNG files in the directory of this example. path_current_example = os.path.dirname(block_vars['src_file']) pngs = sorted(glob(os.path.join(path_current_example, '*.png'))) # Iterate through PNGs, copy them to the sphinx-gallery output directory image_names = list() image_path_iterator = block_vars['image_path_iterator'] for png in pngs: if png not in self.seen: self.seen |= set(png) this_image_path = image_names.append(this_image_path) shutil.move(png, this_image_path) # Use the `figure_rst` helper function to generate rST for image files return figure_rst(image_names, gallery_conf['src_dir'])