diff --git a/Makefile b/Makefile index 88a6fd1..360c427 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ html: html_versions: rm -rf $(BUILDDIR)/html_versions/* - sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/html_versions" $(SPHINXOPTS) $(O) + sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/html_versions" -D 'version_sourcedir=$${sourcedir}' $(SPHINXOPTS) $(O) pdf: weasyprint python3 sphinx-tools/make_pdf.py "$(SOURCEDIR)" "$(BUILDDIR)" diff --git a/source/_static/custom.css b/source/_static/custom.css index dadf769..602ca87 100644 --- a/source/_static/custom.css +++ b/source/_static/custom.css @@ -39,3 +39,13 @@ section#guide-de-montage h1 { h3 span.section-number, h4 span.section-number, h5 span.section-number, h6 span.section-number { display: none; } + +.rst-downloads { + padding: 12px; + padding-top: 0; +} + +.rst-downloads a { + color: #fcfcfc; + border: 1px solid grey; +} \ No newline at end of file diff --git a/source/_templates/versions.html b/source/_templates/versions.html index fb3355f..d6a963f 100644 --- a/source/_templates/versions.html +++ b/source/_templates/versions.html @@ -1,8 +1,8 @@ {%- if current_version %}
- Autres versions - v: {{ current_version.name }} + Autres versions + {{ current_version.name }}
@@ -23,5 +23,11 @@ {%- endif %}
+ + {%- if current_version_data.pdf_url %} +
+ Télécharger au format PDF +
+ {% endif %}
{%- endif %} \ No newline at end of file diff --git a/source/conf.py b/source/conf.py index b33db6e..1f9862d 100644 --- a/source/conf.py +++ b/source/conf.py @@ -25,6 +25,7 @@ extensions = [ 'sphinxcontrib.inkscapeconverter', 'sphinx_multiversion', 'rtd_current_version', + 'version_data' ] myst_enable_extensions = [ diff --git a/source/exts/version_data.py b/source/exts/version_data.py new file mode 100644 index 0000000..483b434 --- /dev/null +++ b/source/exts/version_data.py @@ -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