Search code examples
python-sphinxread-the-docs

Download roles are not working on Read the Docs


I'm trying to get a download link to work in Read the Docs using reStructuredText (reST) and Sphinx. In the reST documentation for the download role the example to provide a download link is given as

.. only:: builder_html

   See :download:`this example script <../example.py>`.

When making the html source locally the links appear, but when using a GitHub linked project on Read the Docs, they do not.


Solution

  • As explained in this GitHub Issue Read the Docs uses its own builder called readthedocs. Thus, to include the download links you must also include this builder. For example

    .. only:: builder_html or readthedocs
    
       See :download:`this example script <../example.py>`.