HTML Context¶
The following variables and functions are exposed to the Sphinx HTML builder context in all versions.
Version
Objects¶
All versions will be exposed to the HTML context as Version
objects with the following attributes:
- name¶
The branch or tag name.
- url¶
The URL to the current page in this version.
- version¶
The value of the
version
variable inconf.py
.
- release¶
The value of the
release
variable inconf.py
.
- is_released¶
True
if this version matches the configuredsmv_released_pattern
regular expression, elseFalse
.
Versions¶
The most important variable is versions
, which can be used to iterate over all found (and whitelisted) versions.
- versions¶
An iterable that yields all
Version
objects.<h3>Versions</h3> <ul> {%- for item in versions %} <li><a href="{{ item.url }}">{{ item.name }}</a></li> {%- endfor %} </ul>
- versions.branches¶
You can use the
branches
property of theversions
iterable to get theVersion
objects for all branches.<h3>Branches</h3> <ul> {%- for item in versions.branches %} <li><a href="{{ item.url }}">{{ item.name }}</a></li> {%- endfor %} </ul>
- versions.tags¶
You can use the
tags
property of theversions
iterable to get theVersion
objects for all tags.<h3>Tags</h3> <ul> {%- for item in versions.tags %} <li><a href="{{ item.url }}">{{ item.name }}</a></li> {%- endfor %} </ul>
- versions.releases¶
You can use the
releases
property of theversions
iterable to get allVersion
objects where theìs_released
attribute isTrue
. This is determined by thesmv_released_pattern
in the Configuration.<h3>Releases</h3> <ul> {%- for item in versions.releases %} <li><a href="{{ item.url }}">{{ item.name }}</a></li> {%- endfor %} </ul>
- versions.in_development¶
You can use the
in_development
property of theversions
iterable to get allVersion
objects where theìs_released
attribute isFalse
. This is determined by thesmv_released_pattern
in the Configuration.<h3>In Development</h3> <ul> {%- for item in versions.in_development %} <li><a href="{{ item.url }}">{{ item.name }}</a></li> {%- endfor %} </ul>
Functions¶
Similar to Sphinx’s hasdoc() function.
- vhasdoc(other_version)¶
This function is Similar to Sphinx’s hasdoc() function. It takes
other_version
as string and returnsTrue
if the current document exists in another version.{% if vhasdoc('master') %} This page is available in <a href="../master/index.html">master</a>. {% endif %}
- vpathto(other_version)¶
This function is Similar to Sphinx’s pathto() function. It takes
other_version
as string and returns the relative URL to the current page in the other version. If the current page does not exist in that version, the relative URL to its master_doc is returned instead.{% if vhasdoc('master') %} This page is also available in <a href="{{ vpathto('master') }}">master</a>. {% else %} Go to <a href="{{ vpathto('master') }}">master</a> for the latest docs. {% endif %}
Other Variables¶
- current_version¶
A
Version
object for of the current version being built.<h3>Current Version: {{ current_version.name }}</h3>
- latest_version¶
A
Version
object of the latest released version being built.<h3>Latest Version: {{ current_version.name }}</h3>