You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by zh...@apache.org on 2022/04/08 05:46:43 UTC

[dolphinscheduler] branch dev updated: [CI] Enable CI to remove unexpected files in /docs/img dir (#9393)

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

zhongjiajie pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new d23616fcbc [CI] Enable CI to remove unexpected files in /docs/img dir (#9393)
d23616fcbc is described below

commit d23616fcbcda12c044e42197952538656a71cd75
Author: Eric Gao <er...@gmail.com>
AuthorDate: Fri Apr 8 13:46:35 2022 +0800

    [CI] Enable CI to remove unexpected files in /docs/img dir (#9393)
---
 docs/img_utils.py | 35 ++++-------------------------------
 1 file changed, 4 insertions(+), 31 deletions(-)

diff --git a/docs/img_utils.py b/docs/img_utils.py
index 8a19557520..98ae07dcca 100644
--- a/docs/img_utils.py
+++ b/docs/img_utils.py
@@ -32,16 +32,6 @@ root_dir: Path = Path(__file__).parent
 img_dir: Path = root_dir.joinpath("img")
 doc_dir: Path = root_dir.joinpath("docs")
 
-expect_img_types: Set = {
-    "jpg",
-    "png",
-}
-
-
-def build_pattern() -> re.Pattern:
-    """Build current document image regexp pattern."""
-    return re.compile(f"(/img.*?\\.({'|'.join(expect_img_types)}))")
-
 
 def get_files_recurse(path: Path) -> Set:
     """Get all files recursively from given :param:`path`."""
@@ -68,14 +58,15 @@ def get_paths_rel_path(paths: Set[Path], rel: Path) -> Set:
     return {f"/{path.relative_to(rel)}" for path in paths}
 
 
-def get_docs_img_path(paths: Set[Path], pattern: re.Pattern) -> Set:
+def get_docs_img_path(paths: Set[Path]) -> Set:
     """Get all img syntax from given :param:`paths` using the regexp from :param:`pattern`."""
     res = set()
+    pattern = re.compile(r"/img[\w./-]*")
     for path in paths:
         content = path.read_text()
         find = pattern.findall(content)
         if find:
-            res |= {item[0] for item in find}
+            res |= {item for item in find}
     return res
 
 
@@ -102,16 +93,6 @@ def diff_two_set(first: Set, second: Set) -> Tuple[set, set]:
     return first.difference(second), second.difference(first)
 
 
-def check_diff_img_type() -> Tuple[set, set]:
-    """Check images difference type.
-
-    :return: Tuple[(actual - expect), (expect - actual)]
-    """
-    img = get_files_recurse(img_dir)
-    img_suffix = get_paths_uniq_suffix(img)
-    return diff_two_set(img_suffix, expect_img_types)
-
-
 def check_diff_img() -> Tuple[set, set]:
     """Check images difference files.
 
@@ -120,20 +101,12 @@ def check_diff_img() -> Tuple[set, set]:
     img = get_files_recurse(img_dir)
     docs = get_files_recurse(doc_dir)
     img_rel_path = get_paths_rel_path(img, root_dir)
-    pat = build_pattern()
-    docs_rel_path = get_docs_img_path(docs, pat)
+    docs_rel_path = get_docs_img_path(docs)
     return diff_two_set(docs_rel_path, img_rel_path)
 
 
 def check() -> None:
     """Runner for `check` sub command."""
-    img_type_act, img_type_exp = check_diff_img_type()
-    assert not img_type_act and not img_type_exp, (
-        f"Images type assert failed: \n"
-        f"* difference actual types to expect is: {img_type_act if img_type_act else 'None'}\n"
-        f"* difference expect types to actual is: {img_type_exp if img_type_exp else 'None'}\n"
-    )
-
     img_docs, img_img = check_diff_img()
     assert not img_docs and not img_img, (
         f"Images assert failed: \n"