-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68dea79
commit 058df35
Showing
6 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: ngword check | ||
|
||
on: [push, pull_request, workflow_dispatch] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install requests | ||
- uses: actions/checkout@v2 | ||
- name: check | ||
run: python3 .github/workflows/script/ngword_check.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import glob | ||
import os | ||
import sys | ||
|
||
NGWORD_LIST = [ | ||
("", "<br>", "<br/>"), | ||
("", "</br>", "<br/>"), | ||
("", "algined", "aligned"), | ||
("", "condtion", "condition"), | ||
("", "eror", "error"), | ||
("", "exposion", "exposition"), | ||
("", "noexpcet", "noexcept"), | ||
("", "protmise_type", "promise_type"), | ||
("", "repear", "repeat"), | ||
("", "子ルーチン", "コルーチン"), | ||
("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 | ||
|
||
if ngword in text: | ||
print("{}: the file includes ngword \"{}\". you should fix to \"{}\".".format(filename, ngword, correct)) | ||
found_error = True | ||
return not found_error | ||
|
||
if __name__ == '__main__': | ||
found_error = False | ||
current_dir = os.getcwd() | ||
outer_link_dict = dict() | ||
found_error = False | ||
for p in sorted(list(glob.glob("**/*.md", recursive=True))): | ||
with open(p) as f: | ||
text = f.read() | ||
|
||
if not check_ngword(text, p): | ||
found_error = True | ||
|
||
if found_error: | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters