You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2021/06/16 11:04:37 UTC

[apisix] branch master updated: docs: fix category and add category check (#4429)

This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 93de2a7  docs: fix category and add category check (#4429)
93de2a7 is described below

commit 93de2a7c6c43d9e946b6ad8e31ee00a128d41051
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Wed Jun 16 19:04:30 2021 +0800

    docs: fix category and add category check (#4429)
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 .github/workflows/doc-lint.yml               |  3 ++
 docs/en/latest/architecture-design/plugin.md | 17 +++++++
 docs/en/latest/config.json                   | 12 +++++
 docs/en/latest/plugins.md                    | 39 ---------------
 docs/zh/latest/architecture-design/plugin.md | 17 +++++++
 docs/zh/latest/config.json                   | 25 +++++++---
 docs/zh/latest/plugins.md                    | 39 ---------------
 utils/check-category.py                      | 71 ++++++++++++++++++++++++++++
 8 files changed, 138 insertions(+), 85 deletions(-)

diff --git a/.github/workflows/doc-lint.yml b/.github/workflows/doc-lint.yml
index a81b592..9888676 100644
--- a/.github/workflows/doc-lint.yml
+++ b/.github/workflows/doc-lint.yml
@@ -18,3 +18,6 @@ jobs:
           node-version: '12.x'
       - run: npm install -g markdownlint-cli@0.25.0
       - run: markdownlint '**/*.md'
+      - name: check category
+        run: |
+          ./utils/check-category.py
diff --git a/docs/en/latest/architecture-design/plugin.md b/docs/en/latest/architecture-design/plugin.md
index dfa101f..cda1e8e 100644
--- a/docs/en/latest/architecture-design/plugin.md
+++ b/docs/en/latest/architecture-design/plugin.md
@@ -63,3 +63,20 @@ The plugin configuration is submitted as part of Route or Service and placed und
 Not all plugins have specific configuration items. For example, there is no specific configuration item under `prometheus`. In this case, an empty object identifier can be used.
 
 If a request is rejected by a plugin, there will be warn level log like `ip-restriction exits with http status code 403`.
+
+## Hot reload
+
+APISIX plugins are hot-loaded. No matter you add, delete or modify plugins, and **update codes of plugins in disk**, you don't need to restart the service.
+
+If your APISIX node has the Admin API turned on, just send an HTTP request through admin API:
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/plugins/reload -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT
+```
+
+Note: if you disable a plugin that has been configured as part of your rule (in the `plugins` field of `route`, etc.),
+then its execution will be skipped.
+
+### Hot reload in stand-alone mode
+
+For stand-alone mode, see plugin related section in [stand alone mode](../stand-alone.md).
diff --git a/docs/en/latest/config.json b/docs/en/latest/config.json
index 8057eae..0f145b8 100644
--- a/docs/en/latest/config.json
+++ b/docs/en/latest/config.json
@@ -219,7 +219,19 @@
         },
         {
           "type": "doc",
+          "id": "aws"
+        },
+        {
+          "type": "doc",
+          "id": "mtls"
+        },
+        {
+          "type": "doc",
           "id": "debug-function"
+        },
+        {
+          "type": "doc",
+          "id": "profile"
         }
       ]
     },
diff --git a/docs/en/latest/plugins.md b/docs/en/latest/plugins.md
deleted file mode 100644
index f7a404d..0000000
--- a/docs/en/latest/plugins.md
+++ /dev/null
@@ -1,39 +0,0 @@
----
-title: Plugins
----
-
-<!--
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
--->
-
-## Hot reload
-
-APISIX plugins are hot-loaded. No matter you add, delete or modify plugins, and **update codes of plugins in disk**, you don't need to restart the service.
-
-If your APISIX node has the Admin API turned on, just send an HTTP request through admin API:
-
-```shell
-curl http://127.0.0.1:9080/apisix/admin/plugins/reload -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT
-```
-
-Note: if you disable a plugin which has been configured as part of your rule (in the `plugins` field of `route`, etc.),
-the its execution will be skipped.
-
-### Hot reload in stand-alone mode
-
-For stand-alone mode, see plugin related section in [stand alone mode](stand-alone.md).
diff --git a/docs/zh/latest/architecture-design/plugin.md b/docs/zh/latest/architecture-design/plugin.md
index 33b90b3..24f5885 100644
--- a/docs/zh/latest/architecture-design/plugin.md
+++ b/docs/zh/latest/architecture-design/plugin.md
@@ -68,3 +68,20 @@ local _M = {
 标识即可。
 
 如果一个请求因为某个插件而被拒绝,会有类似这样的 warn 日志:`ip-restriction exits with http status code 403`。
+
+## 热加载
+
+APISIX 的插件是热加载的,不管你是新增、删除还是修改插件,都不需要重启服务。
+
+只需要通过 admin API 发送一个 HTTP 请求即可:
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/plugins/reload -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT
+```
+
+注意:如果你已经在路由规则里配置了某个插件(比如在 `route` 的 `plugins` 字段里面添加了它),然后
+禁用了该插件,在执行路由规则的时候会跳过这个插件。
+
+## stand-alone 模式下的热加载
+
+参考 [stand alone 模式](../stand-alone.md) 文档里关于配置插件的内容。
diff --git a/docs/zh/latest/config.json b/docs/zh/latest/config.json
index d596e85..6b54a61 100644
--- a/docs/zh/latest/config.json
+++ b/docs/zh/latest/config.json
@@ -20,6 +20,10 @@
     },
     {
       "type": "doc",
+      "id": "getting-started"
+    },
+    {
+      "type": "doc",
       "id": "how-to-build"
     },
     {
@@ -127,10 +131,6 @@
         {
           "type": "doc",
           "id": "admin-api"
-        },
-        {
-          "type": "doc",
-          "id": "control-api"
         }
       ]
     },
@@ -143,12 +143,15 @@
       "label": "Others",
       "items": [
         {
-          "type": "doc",
-          "id": "health-check"
+          "type": "category",
+          "label": "Discovery",
+          "items": [
+            "discovery"
+          ]
         },
         {
           "type": "doc",
-          "id": "router-radixtree"
+          "id": "health-check"
         },
         {
           "type": "doc",
@@ -196,7 +199,15 @@
         },
         {
           "type": "doc",
+          "id": "mtls"
+        },
+        {
+          "type": "doc",
           "id": "debug-function"
+        },
+        {
+          "type": "doc",
+          "id": "profile"
         }
       ]
     },
diff --git a/docs/zh/latest/plugins.md b/docs/zh/latest/plugins.md
deleted file mode 100644
index d214683..0000000
--- a/docs/zh/latest/plugins.md
+++ /dev/null
@@ -1,39 +0,0 @@
----
-title: 插件
----
-
-<!--
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
--->
-
-## 热加载
-
-APISIX 的插件是热加载的,不管你是新增、删除还是修改插件,都不需要重启服务。
-
-只需要通过 admin API 发送一个 HTTP 请求即可:
-
-```shell
-curl http://127.0.0.1:9080/apisix/admin/plugins/reload -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT
-```
-
-注意:如果你已经在路由规则里配置了某个插件(比如在 `route` 的 `plugins` 字段里面添加了它),然后
-禁用了该插件,在执行路由规则的时候会跳过这个插件。
-
-## stand-alone 模式下的热加载
-
-参考 [stand alone 模式](stand-alone.md) 文档里关于配置插件的内容。
diff --git a/utils/check-category.py b/utils/check-category.py
new file mode 100755
index 0000000..79c2c75
--- /dev/null
+++ b/utils/check-category.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+# coding: utf-8
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+import json
+import os
+import sys
+from os import path
+
+EXT = ".md"
+
+try:
+    UNICODE_EXISTS = bool(type(unicode))
+except:
+    # Py2
+    unicode = str
+
+def collect_fn(entries, topic):
+    if "id" in topic:
+        fn = topic["id"]
+        entries.append(fn)
+    elif "items" in topic:
+        for item in topic["items"]:
+            if isinstance(item, unicode):
+                entries.append(item)
+            else:
+                collect_fn(entries, item)
+
+def check_category(root):
+    with open(root + "config.json") as f:
+        entries = []
+
+        data = json.load(f)
+        for topic in data["sidebar"]:
+            collect_fn(entries, topic)
+        for e in entries:
+            fn = root + e + EXT
+            if not path.exists(fn):
+                print("Entry %s in the sidebar can't be found" % fn)
+                return False
+
+        deny_list = ["examples/plugins-hmac-auth-generate-signature", "config", "README"]
+        entries.extend(deny_list)
+        existed_files = []
+        for parent, dirs, files in os.walk(root):
+            for fn in files:
+                existed_files.append(path.join(parent[len(root):], path.splitext(fn)[0]))
+        for fn in existed_files:
+            if fn not in entries:
+                print("File %s%s%s is not indexed" % (root, fn, EXT))
+                return False
+        return True
+
+roots = ["docs/en/latest/", "docs/zh/latest/"]
+for r in roots:
+    if not check_category(r):
+        sys.exit(-1)