# sphinx_gallery.downloads

Utilities for downloadable items.

## Functions

sphinx_gallery.downloads.generate_zipfiles(gallery_dir, src_dir, gallery_conf)

  Collects downloadable sources and makes zipfiles of them.

  Collects all source files and Jupyter notebooks in gallery_dir.

  Parameters:

    - gallery_dir (str) – path of the gallery to collect downloadable sources

    - src_dir (str) – The build source directory. Needed to make the reST paths relative.

    - gallery_conf (dict[str, Any]) – Sphinx-Gallery configuration dictionary

  Returns:

    download_rst – RestructuredText to include download buttons to the generated files

  Return type:

    str

sphinx_gallery.downloads.list_downloadable_sources(target_dir, extensions=('.py',))

  Return a list of source files in target_dir.

  Parameters:

    - target_dir (str) – path to the directory where source file are

    - extensions (tuple[str]) – tuple of file extensions to include

  Returns:

    list of paths to all source files in target_dir ending with one of the specified extensions

  Return type:

    list

sphinx_gallery.downloads.python_zip(file_list, gallery_path, extension='.py')

  Store all files in file_list into an zip file.

  Parameters:

    - file_list (list) – Holds all the file names to be included in zip file

    - gallery_path (str) – path to where the zipfile is stored

    - extension (str | None) – In order to deal with downloads of plain source files and jupyter notebooks, if this value is not None, 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.zip, target_dir_jupyter.zip, or target_dir.zip depending on the extension

  Return type:

    str