sphinx_gallery.gen_rst¶
RST file generator¶
Generate the rst files for the examples by iterating over the python example files.
Files that generate images should start with ‘plot’
Functions¶
-
sphinx_gallery.gen_rst.clean_modules()¶ Remove “unload” seaborn from the name space
After a script is executed it can load a variety of setting that one does not want to influence in other examples in the gallery.
-
sphinx_gallery.gen_rst.codestr2rst(codestr, lang='python', lineno=None)¶ Return reStructuredText code block from code string
-
sphinx_gallery.gen_rst.execute_code_block(compiler, src_file, code_block, lineno, example_globals, block_vars, gallery_conf)¶ Executes the code block of the example file
-
sphinx_gallery.gen_rst.extract_intro_and_title(filename, docstring)¶ Extract the first paragraph of module-level docstring. max:95 char
-
sphinx_gallery.gen_rst.figure_rst(figure_list, sources_dir)¶ Given a list of paths to figures generate the corresponding rst
Depending on whether we have one or more figures, we use a single rst call to ‘image’ or a horizontal list.
Parameters: - figure_list (list of str) – Strings are the figures’ absolute paths
- sources_dir (str) – absolute path of Sphinx documentation sources
Returns: - images_rst (str) – rst code to embed the images in the document
- fig_num (int) – number of figures saved
-
sphinx_gallery.gen_rst.generate_dir_rst(src_dir, target_dir, gallery_conf, seen_backrefs)¶ Generate the gallery reStructuredText for an example directory
-
sphinx_gallery.gen_rst.generate_file_rst(fname, target_dir, src_dir, gallery_conf)¶ Generate the rst file for a given example.
Returns: - intro (str) – The introduction of the example
- time_elapsed (float) – seconds required to run the script
-
sphinx_gallery.gen_rst.get_md5sum(src_file)¶ Returns md5sum of file
-
sphinx_gallery.gen_rst.handle_exception(exc_info, src_file, block_vars, gallery_conf)¶
-
sphinx_gallery.gen_rst.md5sum_is_current(src_file)¶ Checks whether src_file has the same md5 hash as the one on disk
-
sphinx_gallery.gen_rst.save_figures(image_path, fig_count, gallery_conf)¶ Save all open matplotlib figures of the example code-block
Parameters: - image_path (str) – Path where plots are saved (format string which accepts figure number)
- fig_count (int) – Previous figure number count. Figure number add from this number
- gallery_conf (dict) – Contains the configuration of Sphinx-Gallery
Returns: - images_rst (str) – rst code to embed the images in the document
- fig_num (int) – number of figures saved
-
sphinx_gallery.gen_rst.save_thumbnail(image_path_template, src_file, file_conf, gallery_conf)¶ Save the thumbnail image
-
sphinx_gallery.gen_rst.scale_image(in_fname, out_fname, max_width, max_height)¶ Scales an image with the same aspect ratio centered in an image with a given max_width and max_height if in_fname == out_fname the image can only be scaled down