sphinx_version_ref

PyPi version PyPi downloads per month Documentation Status
Author:M.J.W. Snippe
Version:0.1
Release:0.1.0

This extension adds a single role to the reStructuredText parser of Sphinx.

:version-ref:

version-ref takes its argument, replaces all occurrences of {version} in it by the string set by the version configuration variable and similarly for all occurrences of {release}. Then it will proces its argument as if it were a normal URI.

Example

Some text in which I would like to reference to this specific version's
repository :version-ref:`See version {version} here!
<https://github.com/max-sn/sphinx_version_ref/tree/{release}>`

Some text in which I would like to reference to this specific version’s repository See version 0.1 here!

Usage

In your conf.py file:

release = '0.1.0'
version = '.'.join(release.split('.')[:2])
extensions = ['sphinx_version_ref']

Where version can of course be any string. The following uses of <ref> then will be parsed as:

Entered as <ref> Parsed as Resulting in
https://docs.com/{version}/index.html `https://docs.com/0.0/index.html`_ https://docs.com/0.1/index.html
Repo version {version} <http://github.com/user/project/tree/{release}> `Repo version 0.0 <http://github.com/user/project/tree/0.1.0a0>`_ Repo version 0.1