Skip to content
Snippets Groups Projects
Commit 84b8fa7c authored by François Grand's avatar François Grand
Browse files

doc: add application version to generated PDFs

refs #578
parent dbfeba3c
No related branches found
No related tags found
2 merge requests!225Release v4.17.0,!188Resolve "Ajouter le numéro de version de Cassiopée sur la documentation"
......@@ -61,3 +61,6 @@ install_jalhyd
# Jalhyd directory (so far, to be removed if we make jalhyd a Git submodule)
/jalhyd
# generated ngHyd version in Latex format (must be in docs folder since docs/pdf_build is first removed by PDF doc generation)
docs/cassiopee_version.tex
......@@ -13,15 +13,16 @@
% Insertion des différents préambules au document
\input{rapport/english/preambule_rapport_english}
\input{rapport_inrae/preambule_inrae}
% Cassiopée version in the form \newcommand{\cassiopeeversion}{x.y.z}
\input{cassiopee_version}
%*******************************************************************************
%Données de titre et d'auteur pour la page de garde, les entêtes et pieds de page
%*******************************************************************************
% Le titre doit être relativement court mais assez explicite
\newcommand{\service}{UMR G-EAU}
\newcommand{\titre}{Cassiopée 4 software}
\newcommand{\sousTitre}{User documentation}
\newcommand{\titre}{Cassiopée software}
\newcommand{\sousTitre}{version \cassiopeeversion\\User documentation}
%Statut du document [rapport final, rapport intermédiaire]
% auteur intellectuel, rédacteur du document, il peut y avoir plusieurs auteurs ; chaque auteur est renseigné sous la forme « Prénom NOM »
\newcommand{\auteur}{David DORCHIES, Mathias CHOUET, François GRAND}
......
......@@ -13,15 +13,16 @@
% Insertion des différents préambules au document
\input{rapport/francais/preambule_rapport_francais}
\input{rapport_inrae/preambule_inrae}
% version de Cassiopée sous la forme \newcommand{\cassiopeeversion}{x.y.z}
\input{cassiopee_version}
%*******************************************************************************
%Données de titre et d'auteur pour la page de garde, les entêtes et pieds de page
%*******************************************************************************
% Le titre doit être relativement court mais assez explicite
\newcommand{\service}{UMR G-EAU}
\newcommand{\titre}{Logiciel Cassiopée 4}
\newcommand{\sousTitre}{Documentation utilisateur}
\newcommand{\titre}{Logiciel Cassiopée}
\newcommand{\sousTitre}{version \cassiopeeversion\\Documentation utilisateur}
%Statut du document [rapport final, rapport intermédiaire]
% auteur intellectuel, rédacteur du document, il peut y avoir plusieurs auteurs ; chaque auteur est renseigné sous la forme « Prénom NOM »
\newcommand{\auteur}{David DORCHIES, Mathias CHOUET, François GRAND}
......
......@@ -167,6 +167,11 @@ def buildPDF(lang):
os.chdir(modelDir)
sourceTexFile = 'cassiopee_doc_' + lang + '.tex'
outputPdfFile = 'cassiopee_doc_' + lang + '.pdf'
# copy Cassiopée version LateX file
cvt = os.path.join( baseDir,'docs/cassiopee_version.tex')
shutil.copy(cvt, modelDir)
os.system(
'latexmk -f -xelatex -pdf -interaction=nonstopmode {} > /dev/null 2>&1'.format(sourceTexFile)
)
......
......@@ -16,7 +16,7 @@
"monkeytest": "npm run ng -- e2e --dev-server-target= --suite=monkeyTest --webdriver-update=false",
"mkdocs": "node scripts/python3.js -m mkdocs build -f mkdocs-fr.yml && node scripts/python3.js -m mkdocs build -f mkdocs-en.yml && node scripts/mkdocs-postprocess.js",
"mkdocs2pdf": "node scripts/python3.js mkdocs2pdf.py",
"preprocess": "node scripts/preprocessors.js && npm run mkdocs",
"preprocess": "node scripts/preprocessors.js && node scripts/extract-nghyd-version.js docs/cassiopee_version.tex && npm run mkdocs",
"start": "npm run preprocess && npm run ng serve -- --host 0.0.0.0 --poll 5000",
"build-no-pdf": "npm run preprocess && npm run ng build -- --configuration production",
"build": "npm run preprocess && npm run mkdocs2pdf && npm run ng build -- --configuration production",
......
/*
* extract Cassiopée version from package.json and write files according to provided paths extension :
* - a LateX file defining a variable in the form \newcommand\{\cassiopeeversion}{x.y.z} for path(s) with .tex extension
* - a plain text file with version value (x.y.z) for path(s) without extension
*/
'use strict';
const fs = require('fs');
const path = require('path');
if (process.argv.length < 3) {
console.error("ERROR : missing output file path(s)\n");
console.error("syntax : extract-nghyd-version <path> [<path> ...]");
console.error(" extract ngHyd current version to given files according to extension");
console.error(" available extensions : .tex (LateX file with variable), <none (plain version in text file)>");
process.exit(1);
}
function createMissingDirs(p) {
const targetDir = path.dirname(p);
if (!fs.existsSync(targetDir)) {
console.log("creating output directory", targetDir)
fs.mkdirSync(targetDir, { recursive: true });
}
}
function writeTex(outPath, ver) {
// make LateX variable
const s = `\\newcommand\{\\cassiopeeversion\}\{${ver}\}`;
// create intermediate folders if necessary
createMissingDirs(outPath)
// write file
console.log("writing LateX file", outPath);
fs.writeFileSync(outPath, s);
}
function writePlain(outPath, ver) {
// create intermediate folders if necessary
createMissingDirs(outPath)
// write file
console.log("writing plain file", outPath);
fs.writeFileSync(outPath, ver);
}
// read package.json
console.log("reading package.json");
var fdata = fs.readFileSync('package.json', 'utf8');
var data = JSON.parse(fdata)
// get Cassiopée version
const ver = data.version
console.log("got ngHyd version", ver);
for (let i = 2; i < process.argv.length; i++) {
const p = process.argv[i];
if (p.endsWith(".tex")) {
writeTex(p, ver);
} else {
writePlain(p, ver);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment