Youen
2 years ago
8 changed files with 123 additions and 9 deletions
@ -0,0 +1,18 @@ |
|||||||
|
{% extends "!page.html" %} |
||||||
|
{% block body %} |
||||||
|
{% if current_version and latest_version and current_version != latest_version %} |
||||||
|
<div class="warning admonition"> |
||||||
|
<p class="admonition-title">Attention</p> |
||||||
|
<p> |
||||||
|
{% if current_version.is_released %} |
||||||
|
Ceci est une ancienne version de la documentation. |
||||||
|
La dernière version est la <a href="{{ vpathto(latest_version.name) }}">{{latest_version.name}}</a>. |
||||||
|
{% else %} |
||||||
|
Ceci est une version en cours de développement. |
||||||
|
La dernière version stable est la <a href="{{ vpathto(latest_version.name) }}">{{latest_version.name}}</a>. |
||||||
|
{% endif %} |
||||||
|
</p> |
||||||
|
</div> |
||||||
|
{% endif %} |
||||||
|
{{ super() }} |
||||||
|
{% endblock %} |
@ -0,0 +1,33 @@ |
|||||||
|
{%- if current_version %} |
||||||
|
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions"> |
||||||
|
<span class="rst-current-version" data-toggle="rst-current-version"> |
||||||
|
<span class="fa fa-book"> Autres versions</span> |
||||||
|
{{ current_version.name }} |
||||||
|
<span class="fa fa-caret-down"></span> |
||||||
|
</span> |
||||||
|
<div class="rst-other-versions"> |
||||||
|
{%- if versions.tags %} |
||||||
|
<dl> |
||||||
|
<dt>Versions</dt> |
||||||
|
{%- for item in versions.tags %} |
||||||
|
<dd><a href="{{ item.url }}">{{ item.name }}</a></dd> |
||||||
|
{%- endfor %} |
||||||
|
</dl> |
||||||
|
{%- endif %} |
||||||
|
{%- if versions.branches %} |
||||||
|
<dl> |
||||||
|
<dt>Branches</dt> |
||||||
|
{%- for item in versions.branches %} |
||||||
|
<dd><a href="{{ item.url }}">{{ item.name }}</a></dd> |
||||||
|
{%- endfor %} |
||||||
|
</dl> |
||||||
|
{%- endif %} |
||||||
|
</div> |
||||||
|
|
||||||
|
{%- if current_version_data.pdf_url %} |
||||||
|
<div class="rst-downloads"> |
||||||
|
<a href="{{current_version_data.pdf_url}}"><span class="fa fa-download"> Télécharger au format PDF</a></span> |
||||||
|
</div> |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
{%- endif %} |
@ -0,0 +1,14 @@ |
|||||||
|
# This tiny sphinx extension will simply copy the current_version (generated by sphinx_multiversion) to the 'version' entry in html_context, so that it is correctly displayed by the ReadTheDocs template |
||||||
|
# You need to have the sphinx_multiversion extension as well |
||||||
|
|
||||||
|
def setup(app): |
||||||
|
app.connect('config-inited', config_inited) |
||||||
|
|
||||||
|
def config_inited(app, config): |
||||||
|
app.connect('html-page-context', html_page_context) |
||||||
|
|
||||||
|
def html_page_context(app, pagename, templatename, context, doctree): |
||||||
|
try: |
||||||
|
context['version'] = context['current_version'].name |
||||||
|
except: |
||||||
|
context['version'] = 'no_version_found' |
@ -0,0 +1,21 @@ |
|||||||
|
# This module can read data from a python file in the source folder. This will read data from the version being built (as opposed to standard sphinx-multiversion behavior that executes python from the working copy) |
||||||
|
# All global variables defined in file current_version_data.py will be put in html_context['current_version_data'] which allows to use them in HTML templates. |
||||||
|
|
||||||
|
import sys |
||||||
|
|
||||||
|
current_version_data = {} |
||||||
|
|
||||||
|
def setup(app): |
||||||
|
app.add_config_value("version_sourcedir", '', "html") |
||||||
|
app.connect('config-inited', config_inited) |
||||||
|
|
||||||
|
def config_inited(app, config): |
||||||
|
app.connect('html-page-context', html_page_context) |
||||||
|
try: |
||||||
|
exec(open(app.config.version_sourcedir + '/current_version_data.py').read(), globals(), current_version_data) |
||||||
|
except: |
||||||
|
print('No file current_version_data.py found') |
||||||
|
pass |
||||||
|
|
||||||
|
def html_page_context(app, pagename, templatename, context, doctree): |
||||||
|
context['current_version_data'] = current_version_data |
Loading…
Reference in new issue