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
versionvariable inconf.py.
- release¶
The value of the
releasevariable inconf.py.
- is_released¶
Trueif this version matches the configuredsmv_released_patternregular 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
Versionobjects.<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
branchesproperty of theversionsiterable to get theVersionobjects 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
tagsproperty of theversionsiterable to get theVersionobjects 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
releasesproperty of theversionsiterable to get allVersionobjects where theìs_releasedattribute isTrue. This is determined by thesmv_released_patternin 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_developmentproperty of theversionsiterable to get allVersionobjects where theìs_releasedattribute isFalse. This is determined by thesmv_released_patternin 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_versionas string and returnsTrueif 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_versionas 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
Versionobject for of the current version being built.<h3>Current Version: {{ current_version.name }}</h3>
- latest_version¶
A
Versionobject of the latest released version being built.<h3>Latest Version: {{ latest_version.name }}</h3>