-
Notifications
You must be signed in to change notification settings - Fork 222
/
Copy pathrun_all_spelling.sh
106 lines (94 loc) · 3.09 KB
/
run_all_spelling.sh
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
98
99
100
101
102
103
104
105
106
#!/bin/bash
# ============================================================================ #
# Copyright (c) 2022 - 2025 NVIDIA Corporation & Affiliates. #
# All rights reserved. #
# #
# This source code and the accompanying materials are made available under #
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #
# Usage:
# bash scripts/run_all_spelling.sh
# -or-
# bash scripts/run_all_spelling.sh -d (only checks files that have changed from main)
# Note: this script intentionally exits upon encountering the first spelling
# error so that you can go fix the error.
cd $(git rev-parse --show-toplevel)
RUN_ON_ALL_FILES=1
__optind__=$OPTIND
OPTIND=1
while getopts "::d" opt; do
case $opt in
d) RUN_ON_ALL_FILES=0
;;
\?) echo "Invalid command line option -$OPTARG" >&2
exit 1
;;
esac
done
OPTIND=$__optind__
CONFIG=.github/workflows/config/spellcheck_config.yml
if [ "$RUN_ON_ALL_FILES" = "1" ]; then
ALL_FILES_TO_CONSIDER=`git ls-files --`
else
ALL_FILES_TO_CONSIDER=`git diff --diff-filter=d --name-only main... --`
fi
NCHECK=0
for f in $ALL_FILES_TO_CONSIDER; do
NCHECK=$((NCHECK+1))
done
echo "Going to check up to $NCHECK files"
# markdown
ff=`find $ALL_FILES_TO_CONSIDER -name "*.md" | grep -v -P "^tpls/"`
NCHECK=0; for f in $ff; do NCHECK=$((NCHECK+1)); done
echo "Beginning markdown check ($NCHECK files to check)"
for f in $ff; do
echo "*** $f ***"
pyspelling -n markdown -c ${CONFIG} -S $f
if [ $? -ne 0 ]; then
exit
fi
done
# rst
ff=`find $ALL_FILES_TO_CONSIDER -name "*.rst" | grep -v -P "^tpls/|_templates"`
NCHECK=0; for f in $ff; do NCHECK=$((NCHECK+1)); done
echo "Beginning rst check ($NCHECK files to check)"
for f in $ff; do
echo "*** $f ***"
pyspelling -n rst -c ${CONFIG} -S $f
if [ $? -ne 0 ]; then
exit
fi
done
# cxx_headers
ff=`find $ALL_FILES_TO_CONSIDER -name "*.h" -o -name "*.hpp" | grep -v -P "^test/|^tpls/|nlopt-src/"`
NCHECK=0; for f in $ff; do NCHECK=$((NCHECK+1)); done
echo "Beginning cxx_headers check ($NCHECK files to check)"
for f in $ff; do
echo "*** $f ***"
pyspelling -n cxx_headers -c ${CONFIG} -S $f
if [ $? -ne 0 ]; then
exit
fi
done
# cxx_examples
ff=`find $ALL_FILES_TO_CONSIDER -name "*.cpp" | grep -E "^docs/sphinx/applications/|^docs/sphinx/targets/|^docs/sphinx/examples/"`
NCHECK=0; for f in $ff; do NCHECK=$((NCHECK+1)); done
echo "Beginning cxx_examples check ($NCHECK files to check)"
for f in $ff; do
echo "*** $f ***"
pyspelling -n cxx_examples -c ${CONFIG} -S $f
if [ $? -ne 0 ]; then
exit
fi
done
# python
ff=`find $ALL_FILES_TO_CONSIDER -name "*.py" | grep -v -P "^python/tests/|^test/|^tpls/|^docs/sphinx/conf.py"`
NCHECK=0; for f in $ff; do NCHECK=$((NCHECK+1)); done
echo "Beginning python check ($NCHECK files to check)"
for f in $ff; do
echo "*** $f ***"
pyspelling -n python -c ${CONFIG} -S $f
if [ $? -ne 0 ]; then
exit
fi
done