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
Show more breadcrumbs
Cassiopée
nghyd
Commits
784cfbb1
Commit
784cfbb1
authored
2 years ago
by
François Grand
Browse files
Options
Downloads
Patches
Plain Diff
refactor(chore): move stylesheet files used by HTML documentation to a single directory
refs
#612
parent
c3b218a5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!225
Release v4.17.0
,
!215
Resolve "Documentation: localiser les dépendances javascript dans un seul dossier"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/mkdocs-postprocess.js
+53
-4
53 additions, 4 deletions
scripts/mkdocs-postprocess.js
with
53 additions
and
4 deletions
scripts/mkdocs-postprocess.js
+
53
−
4
View file @
784cfbb1
...
...
@@ -11,8 +11,6 @@ const destPath_FR_JS = "src/assets/docs/fr/javascripts"; // pour la compilation
const
destPath_EN_JS
=
"
src/assets/docs/en/javascripts
"
;
// pour la compilation en local (anglais)
const
destPath_CSS
=
"
src/assets/docs/stylesheets
"
;
const
destPath_FR_CSS
=
"
src/assets/docs/fr/stylesheets
"
;
// pour la compilation en local (français)
const
destPath_EN_CSS
=
"
src/assets/docs/en/stylesheets
"
;
// pour la compilation en local (anglais)
const
destPath_JS_MJ
=
destPath_JS
+
"
/mathjax
"
;
const
destPath_FR_JS_MJ
=
destPath_FR_JS
+
"
/mathjax
"
;
// pour la compilation en local (français)
...
...
@@ -38,8 +36,6 @@ fs.copySync("docs/mathjax.config.js", destPath_FR_JS + "/mathjax.config.js");
fs
.
copySync
(
"
docs/mathjax.config.js
"
,
destPath_EN_JS
+
"
/mathjax.config.js
"
);
fs
.
copySync
(
"
docs/mathjax-scrollbar.css
"
,
destPath_CSS
+
"
/mathjax-scrollbar.css
"
);
fs
.
copySync
(
"
docs/mathjax-scrollbar.css
"
,
destPath_FR_CSS
+
"
/mathjax-scrollbar.css
"
);
fs
.
copySync
(
"
docs/mathjax-scrollbar.css
"
,
destPath_EN_CSS
+
"
/mathjax-scrollbar.css
"
);
fs
.
copySync
(
"
docs/matomo-tracking.js
"
,
destPath_JS
+
"
/matomo-tracking.js
"
);
fs
.
copySync
(
"
docs/matomo-tracking.js
"
,
destPath_FR_JS
+
"
/matomo-tracking.js
"
);
...
...
@@ -48,3 +44,56 @@ fs.copySync("docs/matomo-tracking.js", destPath_EN_JS + "/matomo-tracking.js");
fs
.
copySync
(
"
node_modules/mermaid/dist/mermaid.min.js
"
,
destPath_JS
+
"
/mermaid.min.js
"
);
fs
.
copySync
(
"
node_modules/mermaid/dist/mermaid.min.js
"
,
destPath_FR_JS
+
"
/mermaid.min.js
"
);
fs
.
copySync
(
"
node_modules/mermaid/dist/mermaid.min.js
"
,
destPath_EN_JS
+
"
/mermaid.min.js
"
);
/*
Ici, on veut que les ressources copiées ci dessus soit accessibles.
mkdocs-xx.yml :
extra_css:
- ../stylesheets/mathjax-scrollbar.css
Fichiers HTML générés :
Par ex src/assets/docs/fr/calculators/maths/solver.html contient <link rel="stylesheet" href="../../stylesheets/mathjax-scrollbar.css">
ce qui fait référence à stylesheets dans src/assets/docs/fr alors qu'on veut référencer stylesheets dans src/assets/docs/
(le chemin généré dépend de l'emplacement du fichier le contenant).
Le problème, c'est que si on modifie extra_css avec ../../stylesheets/mathjax-scrollbar.css, cela génère la même chose
(href="../../stylesheets/mathjax-scrollbar.css") vraisemblablement à cause de site_dir (=docs/fr) qui limite les "remontées"
de niveau de répertoire.
La solution est donc de modifier les fichiers HTML générés pour ajouter ../ dans href="...".
*/
const
cp
=
require
(
'
child_process
'
);
function
execBashCmd
(
cmd
)
{
// console.log(cmd);
// console.log(cp.execSync(cmd, { encoding: 'utf-8' }));
cp
.
execSync
(
cmd
);
}
function
escapeSlash
(
s
)
{
return
s
.
replaceAll
(
'
/
'
,
'
\\\
/
'
);
}
function
escapeDot
(
s
)
{
return
s
.
replaceAll
(
'
\
.
'
,
'
\\
.
'
);
}
function
escapeDoubleQuote
(
s
)
{
return
s
.
replaceAll
(
'
"
'
,
'
\\
"
'
);
}
function
applyEscapes
(
s
)
{
return
escapeDot
(
escapeSlash
(
escapeDoubleQuote
(
s
)));
}
function
replaceHtml
(
base_dir
,
s1
,
s2
)
{
s1
=
applyEscapes
(
s1
);
s2
=
applyEscapes
(
s2
);
const
cmd
=
"
find
"
+
base_dir
+
"
-name '*.html' -exec sed -i
\"
s/
"
+
s1
+
"
/
"
+
s2
+
"
/g
\"
{}
\\\
;
"
;
execBashCmd
(
cmd
);
}
replaceHtml
(
"
src/assets/docs/fr/
"
,
"
../../stylesheets/mathjax-scrollbar.css
"
,
"
../../../stylesheets/mathjax-scrollbar.css
"
);
replaceHtml
(
"
src/assets/docs/en/
"
,
"
../../stylesheets/mathjax-scrollbar.css
"
,
"
../../../stylesheets/mathjax-scrollbar.css
"
);
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