1

I know that I am able to add links to other parts of the documentation or external web links (https://sublime-and-sphinx-guide.readthedocs.io/en/latest/references.html). But is it possible to link to an external document like a powerpoint PPT file?

It would be convenient in the web docs or PDF if the user were able to click on the link to the PPT file, and the file downloaded and opened automatically.

Thank you for your insight!

Henry
  • 195
  • 3
  • 15
  • 1
    It is possible for local files with not so old Internet Explorers. And I do not trust it - true. @KJ – Yunnosch Sep 07 '21 at 17:02
  • 1
    @KJ That is why I used "not so old" instead of "current". ;-) Weird feeling. Like learning of a younger brother to arrive at your highschool, just when you were celebrating that the older bully finally left. After having to repeat a few years.... – Yunnosch Sep 07 '21 at 18:29
  • 1
    Does this answer your question? [Sphinx: generating an external link](https://stackoverflow.com/questions/17189038/sphinx-generating-an-external-link) – Steve Piercy Sep 08 '21 at 02:43
  • @StevePiercy Thank you for the link! This kind of works. I created a relative link to my document, which opens properly from the web docs. The main issues now are 1. The relative path points to a file location above the HTML web docs 2. The relative path for the PDF and web docs are different. I will try to see if there is a way to fix this – Henry Sep 08 '21 at 18:49
  • I found a sleazy solution by putting my PPT documents in the _static directory, which works for both PDF and HTML. I'll make a separate answer and probably just go with this haha – Henry Sep 08 '21 at 19:22

1 Answers1

1

My (sleazy) solution that works for PDF and HTML is to put all my PPT documents in the _static/ directory, configuring the html_static_path variable, then linking to the desired file, like this:

  1. Directory Structure
repo-top/
    conf.py
    _static/
        myDocument.pptx
  1. conf.py
html_static_path = ['_static']
  1. Your RST file
`Display Text <_static/myDocument.pptx>`_.

Documentation about html_static_path https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_static_path

This also seems to be the approach here: https://stackoverflow.com/a/67997311/6647191

  1. I also had to manually replace all absolute file:/// URLs to relative ones using sed. You then have to send the PDF along with the _static directory. This is on Mac
export LC_CTYPE=C
export LANG=C
sed -i '' 's/file:\/\/\/Users\/username\/Desktop\/project/./g' ./_build/filename.pdf
cp -r _static/* ./_build/_static
Henry
  • 195
  • 3
  • 15