From 0fa87f19b02944676644ca84dc5b7c372199a756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Thu, 1 Dec 2022 12:54:54 +0100 Subject: [PATCH] feat(doc): add Cassiopee version in HTML documentation header alse move Mkdocs files to own folder refs #578 --- mkdocs-en.yml => mkdocs/mkdocs-en.yml | 0 mkdocs-fr.yml => mkdocs/mkdocs-fr.yml | 0 package.json | 4 ++-- mkdocs2pdf.py => scripts/mkdocs2pdf.py | 3 ++- scripts/prepare_mkdocs.sh | 26 ++++++++++++++++++++++++++ 5 files changed, 30 insertions(+), 3 deletions(-) rename mkdocs-en.yml => mkdocs/mkdocs-en.yml (100%) rename mkdocs-fr.yml => mkdocs/mkdocs-fr.yml (100%) rename mkdocs2pdf.py => scripts/mkdocs2pdf.py (99%) create mode 100644 scripts/prepare_mkdocs.sh diff --git a/mkdocs-en.yml b/mkdocs/mkdocs-en.yml similarity index 100% rename from mkdocs-en.yml rename to mkdocs/mkdocs-en.yml diff --git a/mkdocs-fr.yml b/mkdocs/mkdocs-fr.yml similarity index 100% rename from mkdocs-fr.yml rename to mkdocs/mkdocs-fr.yml diff --git a/package.json b/package.json index 31400d75d..27d885816 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "e2e": "npm run preprocess && node scripts/check-translations.js && npm run ng -- e2e --suite=regular --webdriver-update=false", "e2equick": "node scripts/check-translations.js && npm run ng -- e2e --dev-server-target= --suite=regular --webdriver-update=false", "monkeytest": "npm run ng -- e2e --dev-server-target= --suite=monkeyTest --webdriver-update=false", - "mkdocs": "python3 -m mkdocs build -f mkdocs-fr.yml && python3 -m mkdocs build -f mkdocs-en.yml && node scripts/mkdocs-postprocess.js", - "mkdocs2pdf": "node scripts/extract-nghyd-version.js build/cassiopee_version.tex && python3 mkdocs2pdf.py && node scripts/mkdocs2pdf-postprocess.js", + "mkdocs": "bash scripts/prepare_mkdocs.sh; cd build; python3 -m mkdocs build -f mkdocs-fr.yml && python3 -m mkdocs build -f mkdocs-en.yml && cd .. && node scripts/mkdocs-postprocess.js", + "mkdocs2pdf": "node scripts/extract-nghyd-version.js build/cassiopee_version.tex && python3 scripts/mkdocs2pdf.py && node scripts/mkdocs2pdf-postprocess.js", "clean": "rm -rf build dist release src/date_revision.ts src/assets/docs", "preprocess": "mkdir -p build; node scripts/preprocessors.js", "start": "npm run preprocess && npm run mkdocs && npm run ng serve -- --host 0.0.0.0 --poll 5000", diff --git a/mkdocs2pdf.py b/scripts/mkdocs2pdf.py similarity index 99% rename from mkdocs2pdf.py rename to scripts/mkdocs2pdf.py index f66b301a9..6e3cf6804 100644 --- a/mkdocs2pdf.py +++ b/scripts/mkdocs2pdf.py @@ -206,7 +206,7 @@ def buildDocForLang(lang): os.makedirs(outputDir, exist_ok=True) # Read config - yamlPath = 'mkdocs-' + lang + '.yml' + yamlPath = 'mkdocs/mkdocs-' + lang + '.yml' dMkdocsYaml = readConfig(yamlPath) # Create string with merged MarkDown @@ -231,6 +231,7 @@ def buildDocForLang(lang): # Clean build dir shutil.rmtree(pdfBuildDir) + #raise RuntimeError() if __name__ == '__main__': diff --git a/scripts/prepare_mkdocs.sh b/scripts/prepare_mkdocs.sh new file mode 100644 index 000000000..af53d10dc --- /dev/null +++ b/scripts/prepare_mkdocs.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -o errexit + +BUILD_DIR=build +VER_FILE=$BUILD_DIR/cassiopee_version + +function prepareMkdocs +{ + local lang=$1 + + # copy and modify Mkdocs configuration file : + # - add Cassiopée version + # - modify path to input files + # - modify path to output files + cat mkdocs/mkdocs-$lang.yml \ + | sed "/^site_name:/ s/$/ v$VER/" \ + | sed "/^docs_dir:/ s/docs_dir: /docs_dir: ..\//" \ + | sed "/^site_dir:/ s/site_dir: /site_dir: ..\//" > $BUILD_DIR/mkdocs-$1.yml +} + +node scripts/extract-nghyd-version.js $VER_FILE +VER=$(cat $VER_FILE) + +prepareMkdocs fr +prepareMkdocs en -- GitLab