{ "cells": [ { "cell_type": "markdown", "metadata": { "nbsphinx": "hidden" }, "source": [ "This notebook is part of the `nbsphinx` documentation: https://nbsphinx.readthedocs.io/." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Prolog and Epilog\n", "\n", "When including notebooks in your Sphinx documentation, you can choose to add some generic content before and after each notebook.\n", "This can be done with the configuration values `nbsphinx_prolog` and `nbsphinx_epilog` in the file `conf.py`.\n", "\n", "The prolog and epilog strings can hold arbitrary [reST](https://www.sphinx-doc.org/rest.html) markup.\n", "Particularly, the [only](https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-only) and [raw](https://docutils.readthedocs.io/en/sphinx-docs/ref/rst/directives.html#raw-data-pass-through) directives can be used to have different content for HTML and LaTeX output.\n", "\n", "Those strings are also processed by the [Jinja2](http://jinja.pocoo.org/) templating engine.\n", "This means you can run Python-like code within those strings.\n", "You have access to the current [Sphinx build environment](https://www.sphinx-doc.org/en/master/extdev/envapi.html) via the variable `env`.\n", "Most notably, you can get the file name of the current notebook with\n", "\n", " {{ env.doc2path(env.docname, base=None) }}\n", "\n", "Have a look at the [Jinja2 template documentation](http://jinja.pocoo.org/docs/latest/templates/) for more information.\n", "\n", "