Skip to content

Commit

Permalink
[improve] add md-lint command and docs (apache#2640)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuluo-yx authored Aug 31, 2024
1 parent 049c093 commit 19955fa
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"config": {
"default": true,
"MD001": true,
"MD052": false,
"MD003": false,
"MD013": {
"line_length": 600,
Expand All @@ -35,7 +34,8 @@
"MD040": true,
"MD045": false,
"MD046": true,
"MD047": true
"MD047": true,
"MD052": false
},
"ignore": [
"node_modules/",
Expand Down
18 changes: 18 additions & 0 deletions home/docs/community/document.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ This website is compiled using node, using Docusaurus framework components
5. In `home` directory run `npm run start-zh-cn`, you can visit <http://localhost:3000> to view the Chinese mode preview of the site
6. To generate static website resource files, run `npm run build`. The static resources of the build are in the build directory.

## Document Format Inspection

In Apache Hertzbeat, all MD articles have to pass MD's [CI](https://github.com/apache/hertzbeat/blob/master/.github/workflows/doc-build-test.yml) inspection before they can be merged. The purpose is to keep the website looking nice and the formatting of the articles consistent.

After you have written an MD article, you can execute the following command locally to check whether the content of the MD article meets the requirements, so as to reduce the workload of review and save your time:

```shell
cd home && yarn

yarn md-lint

# If the documentation is wrong, you can use yarn md-lint-fix to fix it.
yarn md-lint-fix
```

For formatting rules for MD articles you can refer to: [Markdown-lint-rules](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md)
MD format configuration file in the project: [.markdownlint-cli2.jsonc](https://github.com/apache/hertzbeat/blob/master/.markdownlint-cli2.jsonc)

## Directory structure

```html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ git clone [email protected]:<your-github-user-name>/hertzbeat.git
5.`home`目录下运行 `npm run start-zh-cn`,您可以访问 <http://localhost:3000> 查看站点的中文模式预览
6. 若要生成静态网站资源文件,请运行 `npm run build`。构建的静态资源位于 build 目录中。

## 文档格式检验

在 Apache Hertzbeat 中,所有的 MD 文章都要通过 MD 的 [CI](https://github.com/apache/hertzbeat/blob/master/.github/workflows/doc-build-test.yml) 检测才能够合并,目的是为了保持文档官网的美观和文章格式的一致性。

在您编写了相关 MD 文章之后,您可以在本地执行以下命令,预先检查 MD 的文章内容是否符合要求,减少 review 的工作量,节省您的时间:

```shell
cd home && yarn

yarn md-lint

# 如果文档错误,您可以使用 yarn md-lint-fix 修复
yarn md-lint-fix
```

MD 文章的相关格式规则您可以参考:[Markdown-lint-rules](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md)
项目中的 MD 格式配置文件:[.markdownlint-cli2.jsonc](https://github.com/apache/hertzbeat/blob/master/.markdownlint-cli2.jsonc)

## 目录结构

```html
Expand Down
7 changes: 5 additions & 2 deletions home/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"serve": "docusaurus serve",
"clear": "docusaurus clear",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids"
"write-heading-ids": "docusaurus write-heading-ids",
"md-lint": "markdownlint-cli2 --config ../.markdownlint-cli2.jsonc \"./**/*.md\" \"#node_modules\"",
"md-lint-fix": "yarn md-lint --fix"
},
"dependencies": {
"@docusaurus/core": "2.3.1",
Expand All @@ -39,7 +41,8 @@
"swiper": "7.4.1",
"url-loader": "4.1.1",
"workbox-routing": "6.5.3",
"workbox-strategies": "6.5.3"
"workbox-strategies": "6.5.3",
"markdownlint-cli2": "^0.13.0"
},
"browserslist": {
"production": [
Expand Down

0 comments on commit 19955fa

Please sign in to comment.