Sphinx tips and tricks 🔗

Tips and tricks for using Sphinx.

Ubiquitous includes 🔗

There are often substitutions and link targets that I'll use on many---if not all---pages in my documentation set. An easy way to do this is to feed rst_epilog with the contents of the file you want to include on every page.

# Make the contents of this file available on *every* page.
with open('_includes.txt') as f:
   rst_epilog = f.read()

This way, you don't need to add:

.. include:: _includes.txt

...at the end (or beginning) of every file. Nor do you need to add them all to a string directly within conf.py.

Alternatively, you can use rst_prolog for this, which will just add the contents at the beginning of your page contents instead.