# tools/gen_gallery.py script

Generate the images and rst files for gallery of SfePy examples.

The following steps need to be made to regenerate the documentation with the updated example files:

1. remove doc/examples/*:

       $ rm -rf doc/examples/*

2. generate the files:

   $ ./tools/gen_gallery.py

3. regenerate the documentation:

       $ python setup.py htmldocs

gen_gallery.apply_view_options(views, default)

gen_gallery.ebase2fbase(ebase)

gen_gallery.generate_gallery(examples_dir, output_filename, doc_dir, rst_dir, thumbnails_dir, dir_map, n_col=3)

  Generate the gallery rst file with thumbnail images and links to examples.

  Parameters:
    output_filename str

      The output rst file name.

    doc_dir str

      The top level directory of gallery files.

    rst_dir str

      The full path to rst files of examples within doc_dir.

    thumbnails_dir str

      The full path to thumbnail images within doc_dir.

    dir_map dict

      The directory mapping returned by generate_rst_files()

    n_col int

      The number of columns in the gallery table.

gen_gallery.generate_images(images_dir, examples_dir, pattern='*.py')

  Generate images from results of running examples found in examples_dir directory.

  The generated images are stored to images_dir,

gen_gallery.generate_rst_files(rst_dir, examples_dir, images_dir, pattern='*.py')

  Generate Sphinx rst files for examples in examples_dir with images in images_dir and put them into rst_dir.

  Returns:
    dir_map dict

      The directory mapping of examples and corresponding rst files.

gen_gallery.generate_thumbnails(thumbnails_dir, images_dir, scale=0.3)

  Generate thumbnails into thumbnails_dir corresponding to images in images_dir.

gen_gallery.main()

gen_gallery.resview_plot(filename, filename_out, options)

gen_gallery.run_resview_plot(*args)

  A fix for the problem that calling `resview_plot()` directly often terminates the program.