Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nghyd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
A compter du 1er avril, attention à vos pipelines :
Nouvelles limitations de Docker Hub
Show more breadcrumbs
Cassiopée
nghyd
Commits
74dbe94f
Commit
74dbe94f
authored
2 years ago
by
François Grand
Browse files
Options
Downloads
Patches
Plain Diff
refactor(doc): improve PDF generation
refs
#604
parent
7f5d19dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!225
Release v4.17.0
,
!206
Resolve "PWA: l'application ne se met pas à jour"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
README.md
+1
-1
1 addition, 1 deletion
README.md
scripts/mkdocs2pdf.py
+42
-35
42 additions, 35 deletions
scripts/mkdocs2pdf.py
with
44 additions
and
36 deletions
.gitignore
+
1
−
0
View file @
74dbe94f
...
...
@@ -7,6 +7,7 @@
/src/assets/docs
/release
/build
/docs/pdf_build
# dependencies
/node_modules
...
...
This diff is collapsed.
Click to expand it.
README.md
+
1
−
1
View file @
74dbe94f
...
...
@@ -14,7 +14,7 @@ Requirements for developping Cassiopee can be achieved by manually install the r
*
npm
*
python3
*
pandoc ^2 (optional, for PDF documentation only)
*
texlive (optional, for PDF documentation only)
*
texlive
, texlive-bibtex-extra, texlive-latex-extra, latexmk
(optional, for PDF documentation only)
Building the HTML documentation requires MkDocs and some extensions:
...
...
This diff is collapsed.
Click to expand it.
scripts/mkdocs2pdf.py
+
42
−
35
View file @
74dbe94f
...
...
@@ -20,6 +20,9 @@ import yaml
import
re
import
shutil
# verbose output
verbose
=
False
baseDir
=
os
.
getcwd
()
buildDir
=
os
.
path
.
join
(
baseDir
,
'
build
'
)
latexSourceDir
=
os
.
path
.
join
(
baseDir
,
'
docs/latex
'
)
...
...
@@ -38,6 +41,21 @@ def runCommand(cmd):
if
os
.
waitstatus_to_exitcode
(
os
.
system
(
cmd
))
!=
0
:
raise
RuntimeError
(
"
error executing:
"
,
cmd
)
# Create a symbolic link
def
createLink
(
src
):
# check if destination already exists
dest
=
os
.
path
.
basename
(
src
)
if
os
.
path
.
exists
(
dest
):
if
not
os
.
path
.
islink
(
dest
):
raise
Exception
(
'
{} exists but is not a symbolic link
'
.
format
(
dest
))
else
:
runCommand
(
'
ln -s {}
'
.
format
(
src
))
def
createEmptyDir
(
path
):
if
os
.
path
.
exists
(
path
):
shutil
.
rmtree
(
path
)
os
.
makedirs
(
path
)
# Reads an MkDocs configuration file
def
readConfig
(
sYAML
):
f
=
open
(
sYAML
,
'
r
'
)
...
...
@@ -130,9 +148,14 @@ def convertMdToTex(filePath):
def
getLatexModel
():
# Clone Git repository
os
.
chdir
(
pdfBuildDir
)
runCommand
(
'
git clone {} {}
'
.
format
(
latexModelRepository
,
latexModelDir
)
)
if
os
.
path
.
isdir
(
latexModelDir
):
# git directory exists, update it
os
.
chdir
(
latexModelDir
)
runCommand
(
'
git pull
'
)
# platform independent "cd .."
os
.
chdir
(
os
.
path
.
dirname
(
os
.
getcwd
()))
else
:
runCommand
(
'
git clone {} {}
'
.
format
(
latexModelRepository
,
latexModelDir
))
# back to original working drectory
os
.
chdir
(
baseDir
)
...
...
@@ -146,35 +169,17 @@ def injectContentIntoModel(mergedDocFilenameTex, lang):
# Symlink necessary resources
os
.
chdir
(
modelDir
)
relPathToMergedTexDoc
=
os
.
path
.
join
(
'
..
'
,
mergedDocFilenameTex
)
runCommand
(
'
ln -s {} .
'
.
format
(
relPathToMergedTexDoc
)
)
createLink
(
relPathToMergedTexDoc
)
latexTemplate
=
filenamePrefix
+
lang
+
'
.tex
'
relPathToLatexTemplate
=
os
.
path
.
join
(
latexSourceDir
,
latexTemplate
)
runCommand
(
'
ln -s {}
'
.
format
(
relPathToLatexTemplate
)
)
runCommand
(
'
ln -s {}
'
.
format
(
os
.
path
.
join
(
latexSourceDir
,
'
logo_pole.png
'
))
)
runCommand
(
'
ln -s {}/schema_rugosite_fond.png
'
.
format
(
os
.
path
.
join
(
baseDir
,
'
docs
'
,
lang
,
'
calculators
'
,
'
pam
'
))
)
runCommand
(
'
ln -s {}/bloc_cylindre.png
'
.
format
(
os
.
path
.
join
(
baseDir
,
'
docs
'
,
lang
,
'
calculators
'
,
'
pam
'
))
)
runCommand
(
'
ln -s {}/bloc_face_arrondie.png
'
.
format
(
os
.
path
.
join
(
baseDir
,
'
docs
'
,
lang
,
'
calculators
'
,
'
pam
'
))
)
runCommand
(
'
ln -s {}/bloc_base_carree.png
'
.
format
(
os
.
path
.
join
(
baseDir
,
'
docs
'
,
lang
,
'
calculators
'
,
'
pam
'
))
)
runCommand
(
'
rm rapport_inrae/logos.tex
'
)
runCommand
(
'
ln -s {} rapport_inrae/
'
.
format
(
os
.
path
.
join
(
latexSourceDir
,
'
logos.tex
'
))
)
createLink
(
relPathToLatexTemplate
)
createLink
(
os
.
path
.
join
(
latexSourceDir
,
'
logo_pole.png
'
))
createLink
(
'
{}/schema_rugosite_fond.png
'
.
format
(
os
.
path
.
join
(
baseDir
,
'
docs
'
,
lang
,
'
calculators
'
,
'
pam
'
)))
createLink
(
'
{}/bloc_cylindre.png
'
.
format
(
os
.
path
.
join
(
baseDir
,
'
docs
'
,
lang
,
'
calculators
'
,
'
pam
'
)))
createLink
(
'
{}/bloc_face_arrondie.png
'
.
format
(
os
.
path
.
join
(
baseDir
,
'
docs
'
,
lang
,
'
calculators
'
,
'
pam
'
)))
createLink
(
'
{}/bloc_base_carree.png
'
.
format
(
os
.
path
.
join
(
baseDir
,
'
docs
'
,
lang
,
'
calculators
'
,
'
pam
'
)))
runCommand
(
'
rm rapport_inrae/logos.tex
'
)
createLink
(
'
{} rapport_inrae/
'
.
format
(
os
.
path
.
join
(
latexSourceDir
,
'
logos.tex
'
)))
# back to original working drectory
os
.
chdir
(
baseDir
)
...
...
@@ -189,9 +194,11 @@ def buildPDF(lang):
cvt
=
os
.
path
.
join
(
buildDir
,
'
cassiopee_version.tex
'
)
shutil
.
copy
(
cvt
,
modelDir
)
os
.
system
(
'
latexmk -f -xelatex -pdf -interaction=nonstopmode {} > /dev/null 2>&1
'
.
format
(
sourceTexFile
)
)
if
verbose
:
os
.
system
(
'
latexmk -f -xelatex -pdf -interaction=nonstopmode {} > /dev/null
'
.
format
(
sourceTexFile
))
else
:
os
.
system
(
'
latexmk -f -xelatex -pdf -interaction=nonstopmode {} > /dev/null 2>&1
'
.
format
(
sourceTexFile
))
# copy generated PDF to release directory
shutil
.
copy
(
outputPdfFile
,
outputDir
)
# back to original working drectory
...
...
@@ -201,9 +208,9 @@ def buildPDF(lang):
def
buildDocForLang
(
lang
):
# Prepare temporary build directory
os
.
maked
ir
s
(
pdfBuildDir
,
exist_ok
=
True
)
createEmptyD
ir
(
pdfBuildDir
)
# Prepare output directory
os
.
maked
ir
s
(
outputDir
,
exist_ok
=
True
)
createEmptyD
ir
(
outputDir
)
# Read config
yamlPath
=
'
mkdocs/mkdocs-
'
+
lang
+
'
.yml
'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment