Переглянути джерело

fix(acthon): add markdown check action (#697)

Ming 4 роки тому
батько
коміт
760c1edc4e

+ 25 - 0
.github/workflows/check_markdown.yaml

@@ -0,0 +1,25 @@
+name: Check markdown
+
+on: [push, pull_request]
+
+jobs:
+  Markdown_Checker:
+    runs-on: ubuntu-latest
+    steps:
+    - name: Check out code
+      uses: actions/checkout@main
+  
+    - name: Install markdownlint
+      run: sudo npm install -g markdownlint-cli
+
+    - name: Check markdown
+      run: markdownlint -c .github/workflows/markdown_config.json ./docs/
+
+  Directory_Checker:
+    runs-on: ubuntu-latest
+    steps:
+    - name: Check out code
+      uses: actions/checkout@main
+  
+    - name: Check directory config
+      run: python3 .github/workflows/directory_check.py $(pwd)/docs/

+ 59 - 0
.github/workflows/directory_check.py

@@ -0,0 +1,59 @@
+import os
+import sys
+import json
+import re
+
+docs_path = sys.argv[1]
+success = True
+
+def check_path(path_list, folder):
+    global success
+    for i in path_list:
+        md_path = i.get('path')
+        md_children = i.get('children')
+        if md_path and md_children:
+            print(f'{i.get("title")} has path and children')
+            success = False
+        if md_children:
+            check_path(md_children, folder)
+        else:
+            if md_path.startswith(('http://', 'https://')) or md_path == './':
+                continue
+            file_path = f'{docs_path}/{folder}/{md_path}.md'
+
+            if not os.path.exists(file_path):
+                print(f'{folder}/{md_path}.md not exists')
+                success = False
+                continue
+
+            md_content = open(file_path, 'r').read()
+            image_list = re.findall('(.*?)!\[(.*?)\]\((.*?)\)', md_content)
+            for image in image_list:
+                if image[0].startswith('<!--'):
+                    continue
+                if image[2].startswith(('http://', 'https://', '<')):
+                    continue
+                image_path = os.path.join(f'{"/".join(file_path.split("/")[:-1])}/', image[2])
+
+                if not os.path.exists(image_path):
+                    print(f'In {folder}/{md_path}.md:', end='')
+                    print(image[2], 'does not exist')
+                    success = False
+
+
+if __name__ == '__main__':
+    file_list = []
+    if os.path.exists(f'{docs_path}/directory.json'):
+        file_list.append('directory.json')
+
+    for file in file_list:
+        with open(f'{docs_path}/{file}') as f:
+            print(f'Check {file}...')
+            config_dict = json.load(f)
+            check_path(config_dict['cn'], 'zh_CN')
+            check_path(config_dict['en'], 'en_US')
+
+    if not success:
+        sys.exit('No pass!')
+    else:
+        print('Check completed!')

+ 13 - 0
.github/workflows/markdown_config.json

@@ -0,0 +1,13 @@
+{
+    "default": false,
+    "MD001": true,
+    "MD003": {"style": "atx"},
+    "MD011": true,
+    "MD018": true,
+    "MD019": true,
+    "MD023": true,
+    "MD025": {"level": 1, "front_matter_title": ""},
+    "MD042": true,
+    "MD046": {"style": "fenced"},
+    "MD048": {"style": "backtick"}
+  }

+ 2 - 2
docs/en_US/README.md

@@ -120,11 +120,11 @@ Join our [Slack](https://join.slack.com/t/emqx/shared_invite/zt-7xrracuf-GGdbNB1
 
 ## Build from source
 
-#### Preparation
+### Preparation
 
 - Go version >= 1.13
 
-#### Compile
+### Compile
 
 + Binary: 
 

+ 2 - 2
docs/en_US/operation/configuration_file.md

@@ -39,10 +39,10 @@ basic:
     keyfile: /var/https-server.key
 ```
 
-#### restPort
+### restPort
 The port for the rest api http server to listen to.
 
-#### restTls
+### restTls
 The tls cert file path and key file path setting. If restTls is not set, the rest api server will listen on http. Otherwise, it will listen on https.
 
 ## Prometheus Configuration

+ 4 - 4
docs/en_US/plugins/functions/functions.md

@@ -2,7 +2,7 @@
 
 Kuiper can customize functions. For the development, compilation and use of functions, please [see here](../../extension/function.md).
 
-### echo plugin
+## echo plugin
 
 | Function | Example   | Description                     |
 | -------- | --------- | ------------------------------- |
@@ -16,7 +16,7 @@ echo(avg) example
   SELECT echo(avg) as r1 FROM test;
   ```
 
-### countPlusOne plugin
+## countPlusOne plugin
 
 | Function     | Example           | Description                                       |
 | ------------ | ----------------- | ------------------------------------------------- |
@@ -30,7 +30,7 @@ countPlusOne(avg) example
   SELECT countPlusOne(avg) as r1 FROM test;
   ```
 
-### accumulateWordCount plugin
+## accumulateWordCount plugin
 
 | Function            | Example                      | Description                                  |
 | ------------------- | ---------------------------- | -------------------------------------------- |
@@ -44,7 +44,7 @@ accumulateWordCount(avg,sep) example
   SELECT accumulateWordCount(avg,sep) as r1 FROM test;
   ```
 
-### Image processing plugin
+## Image processing plugin
 
 Image processing currently only supports the formats of `png` and `jpeg` 
 

+ 3 - 3
docs/en_US/plugins/sinks/influx.md

@@ -36,7 +36,7 @@ Restart the Kuiper server to activate the plugin.
 
 Below is a sample for selecting temperature great than 50 degree, and some profiles only for your reference.
 
-#### /tmp/influxRule.txt
+### /tmp/influxRule.txt
 ```json
 {
   "id": "influx",
@@ -58,13 +58,13 @@ Below is a sample for selecting temperature great than 50 degree, and some profi
   ]
 }
 ```
-#### /tmp/influxPlugin.txt
+### /tmp/influxPlugin.txt
 ```json
 {
    "file":"http://localhost:8080/influx.zip"
  }
 ```
-#### plugins/go.mod
+### plugins/go.mod
 ```
 module plugins
 

Різницю між файлами не показано, бо вона завелика
+ 8 - 8
docs/en_US/rules/overview.md


+ 13 - 13
docs/en_US/streams.md

@@ -1,7 +1,7 @@
-## Stream specs 
+# Stream specs 
 
 
-### Data types
+## Data types
 
 Refer to [Azure IoT](https://docs.microsoft.com/en-us/stream-analytics-query/data-types-azure-stream-analytics), boolean type is cast to int.
 
@@ -17,9 +17,9 @@ Refer to [Azure IoT](https://docs.microsoft.com/en-us/stream-analytics-query/dat
 
 
 
-### Language definitions
+## Language definitions
 
-#### CREATE STREAM
+### CREATE STREAM
 
 ```sql
 CREATE STREAM   
@@ -102,7 +102,7 @@ demo: #Conf_key
 
 ```
 
-#### DROP STREAM
+### DROP STREAM
 
 DROP the stream.
 
@@ -110,7 +110,7 @@ DROP the stream.
 DROP STREAM my_stream
 ```
 
-#### DESCRIBE STREAM
+### DESCRIBE STREAM
 
 Print the stream definition.
 
@@ -128,7 +128,7 @@ Format: json
 Key: id
 ```
 
-#### EXPLAIN STREAM
+### EXPLAIN STREAM
 
 Print the detailed runtime infomation of the stream.
 
@@ -136,7 +136,7 @@ Print the detailed runtime infomation of the stream.
 EXPLAIN STREAM my_stream
 ```
 
-#### SHOW STREAMS
+### SHOW STREAMS
 
 Print all defined streams in system.
 
@@ -148,11 +148,11 @@ my_stream, iot_stream
 
 
 
-### A simple CLI
+## A simple CLI
 
 A simple command line tool is implemented in ``stream/cli/main.go``. 
 
-#### Run sql to manage streams
+### Run sql to manage streams
 
 Run `kuiper stream` command, after `kuiper >` prompt shown, enter stream related sql statements such as create, drop, describe, explain and show stream statements to execute.
 
@@ -164,7 +164,7 @@ kuiper > DESCRIBE STREAM sname
 ```
 
 
-#### Run query
+### Run query
 
 ```bash
 cli query
@@ -174,9 +174,9 @@ kuiper > select USERID from demo;
 
 
 
-### Implementation
+## Implementation
 
-##### How to save the stream definitions?
+### How to save the stream definitions?
 
 Refer to below, a storage is required for saving the stream definitions.
 

+ 2 - 2
docs/zh_CN/README.md

@@ -120,11 +120,11 @@ Kuiper 可以运行在各类物联网的边缘使用场景中,比如工业物
 
 ## 从源码编译
 
-#### 准备
+### 准备
 
 + Go version >= 1.13
 
-#### 编译
+### 编译
 
 + 编译二进制:
 

Різницю між файлами не показано, бо вона завелика
+ 11 - 11
docs/zh_CN/edgex/edgex_rule_engine_tutorial.md


+ 7 - 7
docs/zh_CN/extension/overview.md

@@ -1,9 +1,3 @@
-## 命名
-
-建议插件名使用 camel case 形式。插件命名有一些限制:
-1. 插件输出变量必须为**插件名的首字母大写形式**。 例如,插件名为 _file_ ,则其输出变量名必须为 _File_。
-2. _.so_ 文件的名字必须与输出变量名或者插件名相同。例如, _MySource.so_ 或 _mySink.so_。
-
 # 扩展
 
 Kuiper 允许用户自定义不同类型的扩展。 
@@ -18,7 +12,13 @@ Kuiper 允许用户自定义不同类型的扩展。
 - [Sink/Action 扩展](./sink.md)
 - [函数扩展](./function.md)
 
-### 状态存储
+## 命名
+
+建议插件名使用 camel case 形式。插件命名有一些限制:
+1. 插件输出变量必须为**插件名的首字母大写形式**。 例如,插件名为 _file_ ,则其输出变量名必须为 _File_。
+2. _.so_ 文件的名字必须与输出变量名或者插件名相同。例如, _MySource.so_ 或 _mySink.so_。
+
+## 状态存储
 
 Kuiper 扩展通过 context 参数暴露了一个基于键值对的状态存储接口,可用于所有类型的扩展,包括 Source,Sink 和 Function 扩展.
 

+ 2 - 2
docs/zh_CN/operation/configuration_file.md

@@ -39,10 +39,10 @@ basic:
     keyfile: /var/https-server.key
 ```
 
-#### restPort
+### restPort
 REST http 服务器监听端口
 
-#### restTls
+### restTls
 TLS 证书 cert 文件和 key 文件位置。如果 restTls 选项未配置,则 REST 服务器将启动为 http 服务器,否则启动为 https 服务器。
 
 ## Prometheus 配置

+ 4 - 4
docs/zh_CN/plugins/functions/functions.md

@@ -2,7 +2,7 @@
 
 Kuiper 可以定制函数,函数的开发、编译及使用请[参见这里](../../extension/function.md)。
 
-### echo 插件
+## echo 插件
 
 | 函数 | 示例      | 说明           |
 | ---- | --------- | -------------- |
@@ -16,7 +16,7 @@ echo(avg) 示例
   SELECT echo(avg) as r1 FROM test;
   ```
 
-### countPlusOne 插件
+## countPlusOne 插件
 
 | 函数         | 示例              | 说明                 |
 | ------------ | ----------------- | -------------------- |
@@ -30,7 +30,7 @@ countPlusOne(avg) 示例
   SELECT countPlusOne(avg) as r1 FROM test;
   ```
 
-### accumulateWordCount 插件
+## accumulateWordCount 插件
 
 | 函数                | 示例                         | 说明                     |
 | ------------------- | ---------------------------- | ------------------------ |
@@ -44,7 +44,7 @@ accumulateWordCount(avg,sep) 示例
   SELECT accumulateWordCount(avg,sep) as r1 FROM test;
   ```
 
-### 图像处理插件
+## 图像处理插件
 
 图像处理目前暂时只支持`png`和`jpeg`格式
 

+ 3 - 3
docs/zh_CN/plugins/sinks/influx.md

@@ -35,7 +35,7 @@
 
 下面是选择温度大于50度的样本规则,和一些配置文件仅供参考。
 
-#### ####/tmp/influxRule.txt
+### ####/tmp/influxRule.txt
 ```json
 {
   "id": "influx",
@@ -57,13 +57,13 @@
   ]
 }
 ```
-#### ####/tmp/influxPlugin.txt
+### ####/tmp/influxPlugin.txt
 ```json
 {
   "file":"http://localhost:8080/influx.zip"
 }
 ```
-#### plugins/go.mod
+### plugins/go.mod
 ```
 module plugins
 

+ 13 - 13
docs/zh_CN/streams.md

@@ -1,7 +1,7 @@
-## 流规格 
+# 流规格 
 
 
-### 数据类型
+## 数据类型
 
 参考 [Azure IoT](https://docs.microsoft.com/en-us/stream-analytics-query/data-types-azure-stream-analytics), 将布尔类型强制转换为 int。
 
@@ -17,9 +17,9 @@
 
 
 
-### 语言定义
+## 语言定义
 
-#### 创建流
+### 创建流
 
 ```sql
 CREATE STREAM   
@@ -102,7 +102,7 @@ demo: #Conf_key
 
 ```
 
-#### 删除流
+### 删除流
 
 删除流。
 
@@ -110,7 +110,7 @@ demo: #Conf_key
 DROP STREAM my_stream
 ```
 
-#### 描述流
+### 描述流
 
 打印流定义。
 
@@ -128,7 +128,7 @@ Format: json
 Key: id
 ```
 
-#### 解释流
+### 解释流
 
 打印流的详细运行时信息。
 
@@ -136,7 +136,7 @@ Key: id
 EXPLAIN STREAM my_stream
 ```
 
-#### 显示流
+### 显示流
 
 打印系统中所有已定义的流。
 
@@ -148,11 +148,11 @@ my_stream, iot_stream
 
 
 
-### 一个简单的 CLI
+## 一个简单的 CLI
 
 一个简单的命令行工具在 `stream/cli/main.go` 中实现。
 
-#### 运行 SQL 来管理流
+### 运行 SQL 来管理流
 
 运行 `kuiper stream` 命令,在显示 `kuiper>` 提示后,输入与流相关的 sql 语句,例如create,drop,description,explain和show stream语句以执行操作。
 
@@ -164,7 +164,7 @@ kuiper > DESCRIBE STREAM sname
 ```
 
 
-#### 查询
+### 查询
 
 ```bash
 cli query
@@ -174,9 +174,9 @@ kuiper > select USERID from demo;
 
 
 
-### 实现
+## 实现
 
-##### 如何保存流定义?
+### 如何保存流定义?
 
 请参阅下面的内容,需要使用存储器来保存流定义。