Downloadable Files in Documentation#

This page describes how to provide downloadable files (HTML visualizations, JSON drawings, etc.) alongside embedded content in the Sphinx documentation.

This is useful when an interactive HTML visualization is embedded via <iframe> — the reader can also download the .html file to open it locally in a browser, zoom in, or share it.

Overview#

Three things must be in place:

  1. A data/ directory at the project root containing the files to offer for download.

  2. A symlink doc/_data pointing to that data/ directory, making it visible to Sphinx.

  3. The :download: RST role in .rst source files to generate the download link.

No Sphinx extension or conf.py change is needed. The :download: role is built into Sphinx.

For HTML visualization files that live in doc/source/_static/html/, no symlink is needed — they are already inside the Sphinx source tree. Use a relative path directly.

For data files (JSON drawings)#

.. tip::

   **Drawing file:** :download:`GICLEUR.json </_data/json/RP6541D072_GICLEUR A00.json>`

Checklist#

  1. Place the file in the right location (data/ for data files, doc/source/_static/html/ for visualizations)

  2. Verify the doc/_data symlink exists (for data files only)

  3. Add :download: role in the RST page

  4. Optionally wrap in .. tip:: for visibility

  5. Build docs (make html) and verify the download link works