Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
容器镜像库
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
b4ee425c
未验证
提交
b4ee425c
编辑于
1 year ago
作者:
Peter Leitzen
提交者:
GitLab
1 year ago
浏览文件
操作
下载
补丁
差异文件
Document mermaidlint in documentation guidelines
Run this script in lefthook and static analysis on CI.
上级
d9c12ea5
No related branches found
分支 包含提交
No related tags found
标签 包含提交
无相关合并请求
变更
4
隐藏空白变更内容
行内
左右并排
显示
4 个更改的文件
doc/development/documentation/testing.md
+13
-0
13 个添加, 0 个删除
doc/development/documentation/testing.md
lefthook.yml
+5
-0
5 个添加, 0 个删除
lefthook.yml
scripts/lint/check_mermaid.mjs
+77
-0
77 个添加, 0 个删除
scripts/lint/check_mermaid.mjs
scripts/static-analysis
+1
-0
1 个添加, 0 个删除
scripts/static-analysis
有
96 个添加
和
0 个删除
doc/development/documentation/testing.md
+
13
−
0
浏览文件 @
b4ee425c
...
@@ -308,6 +308,19 @@ included in backticks. For example:
...
@@ -308,6 +308,19 @@ included in backticks. For example:
-
`git clone`
is a command, so it must be lowercase, while Git is the product,
-
`git clone`
is a command, so it must be lowercase, while Git is the product,
so it must have a capital G.
so it must have a capital G.
### Mermaid
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/144328) in GitLab 16.10.
[
Mermaid
](
https://mermaid.js.org/
)
builds charts and diagrams from code.
The
`mermaidlint`
job runs on merge requests that contain changes to Markdown files.
The script (
`scripts/lint/check_mermaid.mjs`
) returns an error if any Markdown
files return a Mermaid syntax error.
To help debug your Mermaid charts, use the
[
Mermaid Live Editor
](
https://mermaid-js.github.io/mermaid-live-editor/edit
)
.
### Vale
### Vale
[
Vale
](
https://vale.sh/
)
is a grammar, style, and word usage linter for the
[
Vale
](
https://vale.sh/
)
is a grammar, style, and word usage linter for the
...
...
此差异已折叠。
点击以展开。
lefthook.yml
+
5
−
0
浏览文件 @
b4ee425c
...
@@ -33,6 +33,11 @@ pre-push:
...
@@ -33,6 +33,11 @@ pre-push:
files
:
git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD
files
:
git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD
glob
:
'
*.{yml,yaml}{,.*}'
glob
:
'
*.{yml,yaml}{,.*}'
run
:
scripts/lint-yaml.sh {files}
run
:
scripts/lint-yaml.sh {files}
mermaidlint
:
tags
:
documentation style,backend style,frontend style
files
:
git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD
glob
:
'
{app,lib,ee,spec,doc,scripts}/**/*.md'
run
:
scripts/lint/check_mermaid.mjs {files}
stylelint
:
stylelint
:
tags
:
stylesheet css style
tags
:
stylesheet css style
files
:
git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD
files
:
git diff --name-only --diff-filter=d $(git merge-base origin/master HEAD)..HEAD
...
...
此差异已折叠。
点击以展开。
scripts/lint/check_mermaid.mjs
0 → 100755
+
77
−
0
浏览文件 @
b4ee425c
#!/usr/bin/env node
// Lint mermaid code in markdown files.
// Usage: scripts/lint/check_mermaid.mjs [files ...]
import
fs
from
'
node:fs
'
;
import
glob
from
'
glob
'
;
import
mermaid
from
'
mermaid
'
;
import
DOMPurify
from
'
dompurify
'
;
import
{
JSDOM
}
from
'
jsdom
'
;
const
jsdom
=
new
JSDOM
(
'
...
'
,
{
pretendToBeVisual
:
true
,
});
global
.
document
=
jsdom
;
global
.
window
=
jsdom
.
window
;
global
.
Option
=
window
.
Option
;
// Workaround to make DOMPurify not fail.
// See https://github.com/mermaid-js/mermaid/issues/5204
DOMPurify
.
addHook
=
()
=>
{};
DOMPurify
.
sanitize
=
(
x
)
=>
x
;
const
defaultGlob
=
"
{app,lib,ee,spec,doc,scripts}/**/*.md
"
;
const
mermaidMatch
=
/```mermaid
(
.*
?)
```/gm
s
;
const
argv
=
process
.
argv
.
length
>
2
?
process
.
argv
.
slice
(
2
)
:
[
defaultGlob
];
const
mdFiles
=
argv
.
flatMap
((
arg
)
=>
glob
.
sync
(
arg
))
console
.
log
(
`Checking
${
mdFiles
.
length
}
markdown files...`
);
// Mimicking app/assets/javascripts/lib/mermaid.js
mermaid
.
initialize
({
// mermaid core options
mermaid
:
{
startOnLoad
:
false
,
},
// mermaidAPI options
theme
:
'
neutral
'
,
flowchart
:
{
useMaxWidth
:
true
,
htmlLabels
:
true
,
},
secure
:
[
'
secure
'
,
'
securityLevel
'
,
'
startOnLoad
'
,
'
maxTextSize
'
,
'
htmlLabels
'
],
securityLevel
:
'
strict
'
,
});
let
errors
=
0
;
await
Promise
.
all
(
mdFiles
.
map
((
path
)
=>
{
const
data
=
fs
.
readFileSync
(
path
,
'
utf8
'
);
const
matched
=
[...
data
.
matchAll
(
mermaidMatch
)];
return
Promise
.
all
(
matched
.
map
((
match
)
=>
{
const
matchIndex
=
match
.
index
;
const
mermaidText
=
match
[
1
];
return
mermaid
.
parse
(
mermaidText
).
catch
((
error
)
=>
{
const
lineNumber
=
data
.
slice
(
0
,
matchIndex
).
split
(
'
\n
'
).
length
;
console
.
log
(
`
${
path
}
:
${
lineNumber
}
: Mermaid syntax error\nError:
${
error
}
\n`
);
errors
+=
1
;
});
}),
);
}),
);
if
(
errors
>
0
)
{
console
.
log
(
`Total errors:
${
errors
}
`
);
// eslint-disable-next-line no-restricted-syntax
console
.
log
(
`To fix these errors, see https://docs.gitlab.com/ee/development/documentation/testing.html#mermaid.`
);
process
.
exit
(
1
);
}
此差异已折叠。
点击以展开。
scripts/static-analysis
+
1
−
0
浏览文件 @
b4ee425c
...
@@ -46,6 +46,7 @@ class StaticAnalysis
...
@@ -46,6 +46,7 @@ class StaticAnalysis
Task
.
new
(
%w[bin/rake config_lint]
,
10
),
Task
.
new
(
%w[bin/rake config_lint]
,
10
),
Task
.
new
(
%w[bin/rake gitlab:sidekiq:all_queues_yml:check]
,
15
),
Task
.
new
(
%w[bin/rake gitlab:sidekiq:all_queues_yml:check]
,
15
),
(
Gitlab
.
ee?
?
Task
.
new
(
%w[bin/rake gitlab:sidekiq:sidekiq_queues_yml:check]
,
11
)
:
nil
),
(
Gitlab
.
ee?
?
Task
.
new
(
%w[bin/rake gitlab:sidekiq:sidekiq_queues_yml:check]
,
11
)
:
nil
),
Task
.
new
(
%w[scripts/lint/check_mermaid.mjs]
,
10
),
Task
.
new
(
%w[yarn run internal:stylelint]
,
8
),
Task
.
new
(
%w[yarn run internal:stylelint]
,
8
),
Task
.
new
(
%w[scripts/lint-conflicts.sh]
,
1
),
Task
.
new
(
%w[scripts/lint-conflicts.sh]
,
1
),
Task
.
new
(
%w[yarn run block-dependencies]
,
1
),
Task
.
new
(
%w[yarn run block-dependencies]
,
1
),
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录