Ajout d'un mécanisme pour définir des données différentes dans chaque version
Possibilité de définir un lien vers le PDF différent dans chaque version
This commit is contained in:
parent
b6c761eaa9
commit
5f48f8f2d3
5 changed files with 41 additions and 3 deletions
21
source/exts/version_data.py
Normal file
21
source/exts/version_data.py
Normal file
|
|
@ -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…
Add table
Add a link
Reference in a new issue