Add NodeJS script to check mermaid
What does this MR do and why?
This MR adds a mermaid linter to check for Syntax errors in doc/**/*.md
.
See #441248 (closed)
Draft?
-
See self-review -
Run script in CI on doc/*
changes -
Run script in lefthook
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Lefthook example |
---|
![]() |
How to set up and validate locally
master
After $ time scripts/lint/check_mermaid.mjs
Checking 2295 markdown files...
real 0m2.347s
user 0m2.654s
sys 0m0.304s
$ time scripts/lint/check_mermaid.mjs "doc/**/*.md"
Checking 2241 markdown files...
real 0m1.615s
user 0m2.052s
sys 0m0.139s
!144322 (merged)
Beforegit revert -m 1 3f32c1e5
scripts/lint/check_mermaid.mjs
Checking 2295 markdown files...
doc/architecture/blueprints/gitlab_services/index.md:109: Mermaid syntax error
Error: Error: Parse error on line 4:
...<.. "*" Environment : Environment "*
-----------------------^
Expecting 'NEWLINE', 'EOF', 'SQS', 'STR', 'GENERICTYPE', 'LABEL', 'STRUCT_START', 'STRUCT_STOP', 'STYLE_SEPARATOR', 'ANNOTATION_END', 'AGGREGATION', 'EXTENSION', 'COMPOSITION', 'DEPENDENCY', 'LOLLIPOP', 'LINE', 'DOTTED_LINE', 'CALLBACK_NAME', 'HREF', 'ALPHA', 'NUM', 'MINUS', 'UNICODE_TEXT', 'BQUOTE_STR', got 'COLON'
doc/development/gitlab_flavored_markdown/specification_guide/index.md:679: Mermaid syntax error
Error: Error: Parse error on line 15:
...endsubgraph output:<br/>test results/ou
----------------------^
Expecting 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'GRAPH', 'DIR', 'subgraph', 'SQS', 'end', 'AMP', 'COLON', 'START_LINK', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'DOWN', 'UP', 'NUM', 'NODE_STRING', 'BRKT', 'MINUS', 'MULT', 'UNICODE_TEXT', got 'TAGSTART'
doc/development/gitlab_flavored_markdown/specification_guide/index.md:755: Mermaid syntax error
Error: Error: Parse error on line 8:
...endsubgraph output:<br/>test results/ou
----------------------^
Expecting 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'GRAPH', 'DIR', 'subgraph', 'SQS', 'end', 'AMP', 'COLON', 'START_LINK', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'DOWN', 'UP', 'NUM', 'NODE_STRING', 'BRKT', 'MINUS', 'MULT', 'UNICODE_TEXT', got 'TAGSTART'
Total errors: 3
To fix these errors, see https://docs.gitlab.com/ee/development/documentation/testing.html#mermaid.
real 0m2.347s
user 0m2.654s
sys 0m0.304s
Edited by Peter Leitzen