Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do a link to a file in rst with sphinx?

I am writing a documentation and I would like to include links to pdf files or zip archives. How can I achieve that using rst language and sphinx ?

If I do that

here is a pdf file : `pdf <doc/mypdf.pdf>`_ 

It does not work because, during the compilation sphinx do not copy the contains of the doc directory (I use the makefile generated by sphinx-quickstart).

On the contrary, using the image directive :

.. image:: img/plop.png 

sphinx does copy the plop.png image in build directory. How can I obtain the same behavior for pdf or zip archive ?

like image 859
Ger Avatar asked Jan 15 '13 20:01

Ger


People also ask

How do you write RST code?

rst. txt is used. In the past a simplified shorthand directive was widely used: A sentence ending with two double colon :: , followed by a new line and an indented block of code.

What is RST Sphinx?

reStructuredText is the default plaintext markup language used by Sphinx. This section is a brief introduction to reStructuredText (reST) concepts and syntax, intended to provide authors with enough information to author documents productively.


1 Answers

A solution is to use the :download: “role” (detailed in the sphinx documentation on roles).

Here is a short example assuming you have a file mypdf.pdf in a directory doc. The directory doc and your rst file must be in the same directory:

here is a pdf file :download:`pdf <doc/mypdf.pdf>` 

Note that you mustn't put a blank space between :download: and the path to the file.

like image 99
Ger Avatar answered Sep 30 '22 16:09

Ger