### Install sphinxext-rediraffe with pip Source: https://sphinxext-rediraffe.readthedocs.io/en/latest/_sources/index.rst.txt Install the sphinxext-rediraffe package from PyPI. ```sh python -m pip install sphinxext-rediraffe ``` -------------------------------- ### Install test dependencies with pytest group Source: https://sphinxext-rediraffe.readthedocs.io/en/latest/_sources/index.rst.txt Install test dependencies for running pytest tests. ```sh python -m pip install --group test ``` -------------------------------- ### Redirects via file (conf.py and redirects.txt) Source: https://sphinxext-rediraffe.readthedocs.io/en/latest/_sources/index.rst.txt Configure redirects from a file in conf.py, and the redirects.txt file format. Filepaths can be wrapped in quotes (single or double), useful for paths containing spaces. ```python rediraffe_redirects = 'redirects.txt' ``` ```text # comments start with '#' 'another file.rst' index.rst another2.rst "another file.rst" ``` -------------------------------- ### Redirects with jinja template (conf.py and template.html) Source: https://sphinxext-rediraffe.readthedocs.io/en/latest/_sources/index.rst.txt Configure a custom redirect template file and the corresponding HTML template. The template is used to render inserted redirecting files. ```python rediraffe_redirects = 'redirects.txt' rediraffe_template = 'template.html' ``` ```html

Your destination is {{to_url}}

``` -------------------------------- ### Redirects with diff checker config Source: https://sphinxext-rediraffe.readthedocs.io/en/latest/_sources/index.rst.txt Configure redirects file and the branch/commit to diff against for the diff checker. ```python rediraffe_redirects = 'redirects.txt' rediraffe_branch = 'main~1' ``` -------------------------------- ### Redirects only (file) Source: https://sphinxext-rediraffe.readthedocs.io/en/latest Configure redirects using a file. The conf.py sets rediraffe_redirects to a filename, and the file contains redirect mappings with optional quoting. ```python rediraffe_redirects = 'redirects.txt' ``` ```text # comments start with '#' 'another file.rst' index.rst another2.rst "another file.rst" ``` -------------------------------- ### Redirects only (dict) Source: https://sphinxext-rediraffe.readthedocs.io/en/latest Configure redirects using a Python dict in conf.py, mapping source files to destinations. ```python rediraffe_redirects = { 'another.rst': 'index.rst', 'another2.rst': 'another.rst', } ``` -------------------------------- ### Run pytest tests headless Source: https://sphinxext-rediraffe.readthedocs.io/en/latest/_sources/index.rst.txt Run the test suite with pytest, using --headless to avoid opening a browser window during selenium tests. ```sh python -m pytest --headless ``` -------------------------------- ### Redirects via dict in conf.py Source: https://sphinxext-rediraffe.readthedocs.io/en/latest/_sources/index.rst.txt Configure redirects as a dict in conf.py. ```python rediraffe_redirects = { 'another.rst': 'index.rst', 'another2.rst': 'another.rst', } ``` -------------------------------- ### Redirects + diff checker Source: https://sphinxext-rediraffe.readthedocs.io/en/latest Enable the diff checker by setting both rediraffe_redirects and rediraffe_branch in conf.py. ```python rediraffe_redirects = 'redirects.txt' rediraffe_branch = 'main~1' ``` -------------------------------- ### Redirects with Jinja template Source: https://sphinxext-rediraffe.readthedocs.io/en/latest Use a Jinja template to render redirecting files. The conf.py sets rediraffe_template to the template filename, and the template uses the to_url variable. ```python rediraffe_redirects = 'redirects.txt' rediraffe_template = 'template.html' ``` ```html

Your destination is {{to_url}}

``` -------------------------------- ### Add sphinxext.rediraffe to Sphinx extensions Source: https://sphinxext-rediraffe.readthedocs.io/en/latest/_sources/index.rst.txt Add the extension to the Sphinx conf.py extensions list. ```python extensions = [ 'sphinxext.rediraffe', ] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.