-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathngword_check.py
More file actions
97 lines (88 loc) · 2.93 KB
/
Copy pathngword_check.py
File metadata and controls
97 lines (88 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import glob
import os
import sys
import re
NGWORD_LIST = [
("", "<br>", "<br/>"),
("", "</br>", "<br/>"),
("", "acccess", "access"),
("", "ALING", "ALIGN"),
("", "alloacte", "allocate"),
("", "alocator", "allocator"),
("", "asssert", "assert"),
("", "asssume", "assume"),
("", "algined", "aligned"),
("", "concpet", "concept"),
("", "condtion", "condition"),
("", "construcitble", "constructible"),
("", "construtible", "constructible"),
("", "contraint", "constraint"),
("", "Dimentional", "Dimensional"),
("", "deccltype", "decltype"),
("", "Doamin", "Domain"),
("", "eror", "error"),
("", "enumrate", "enumerate"),
("", "exectution", "execution"),
("", "expceted", "expected"),
("", "exposion", "exposition"),
("", "functon", "function"),
("", "generetor", "generator"),
("", "greator", "greater"),
("", "invocalbe", "invocable"),
("", "namespase", "namespace"),
("", "noexpcet", "noexcept"),
("", "oeprator", "operator"),
("", "opreator", "operator"),
("", "opton", "option"),
("", "Ohter", "Other"),
("", "poinetr", "pointer"),
("", "protmise_type", "promise_type"),
("", "pvalue", "prvalue"),
("", "Recevier", "Receiver"),
("", "reciever", "receiver"),
("", "refernce", "reference"),
("", "repear", "repeat"),
("", "schedue", "schedule"),
("", "staitc", "static"),
("", "std::range::", "std::ranges::"),
("", "swtich", "switch"),
("", "voaltile", "volatile"),
("", "Updated upstream", ""),
("", "Stashed changes", ""),
("", "アラインメント", "アライメント"),
("", "イテレーター", "イテレータ"),
("", "子ルーチン", "コルーチン"),
("", "移譲", "委譲"),
("", r'型]\((.*?)\)型', "型](link)"),
("", "括弧", "カッコ"),
("", "スロー", "送出"),
("", "constepx", "constexpr"),
("", "wsting", "wstring"),
("", r"\[lin ", "[link "), # コード修飾ミス
("reference/chrono", "dulation", "duration"),
("reference/random", "施行", "試行"),
("reference/random", "疑似", "擬似"),
]
def check_ngword(text: str, filename: str) -> bool:
found_error: bool = False
for target_dir, ngword, correct in NGWORD_LIST:
if not filename.startswith(target_dir):
continue
m = re.search(ngword, text)
if m:
print("{}: the file includes ngword \"{}\". you should fix to \"{}\".".format(filename, ngword, correct))
found_error = True
return not found_error
def check() -> bool:
found_error = False
for p in sorted(list(glob.glob("**/*.md", recursive=True))):
if p.startswith("start_editing/"):
continue
with open(p) as f:
text = f.read()
if not check_ngword(text, p):
found_error = True
return not found_error
if __name__ == '__main__':
if not check():
sys.exit(1)