sphinx_gallery.downloads

Utilities for downloadable items

Functions

sphinx_gallery.downloads.generate_zipfiles(gallery_dir)

Collects all Python source files and Jupyter notebooks in gallery_dir and makes zipfiles of them

Parameters:gallery_dir (string) – path of the gallery to collect downloadable sources
Returns:download_rst – RestructuredText to include download buttons to the generated files
Return type:string
sphinx_gallery.downloads.list_downloadable_sources(target_dir)

Returns a list of python source files is target_dir

Parameters:target_dir (string) – path to the directory where python source file are
Returns:list of paths to all Python source files in target_dir
Return type:list
sphinx_gallery.downloads.python_zip(file_list, gallery_path, extension='.py')

Stores all files in file_list into an zip file

Parameters:
  • file_list (list of strings) – Holds all the file names to be included in zip file
  • gallery_path (string) – path to where the zipfile is stored
  • extension (str) – ‘.py’ or ‘.ipynb’ In order to deal with downloads of python sources and jupyter notebooks the file extension from files in file_list will be removed and replace with the value of this variable while generating the zip file
Returns:

zipname – zip file name, written as target_dir_{python,jupyter}.zip depending on the extension

Return type:

string