Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hpc-compendium
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ZIH
hpcsupport
hpc-compendium
Commits
97108dac
Commit
97108dac
authored
3 years ago
by
Jan Frenzel
Browse files
Options
Downloads
Patches
Plain Diff
Added --all option to check-spelling.sh.
parent
bce1a91d
No related branches found
No related tags found
3 merge requests
!446
docs: Add Jupyter Teaching Example
,
!423
Automated merge from preview to main
,
!421
Added --all option to check-spelling.sh.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc.zih.tu-dresden.de/util/check-spelling.sh
+51
-8
51 additions, 8 deletions
doc.zih.tu-dresden.de/util/check-spelling.sh
with
51 additions
and
8 deletions
doc.zih.tu-dresden.de/util/check-spelling.sh
+
51
−
8
View file @
97108dac
...
...
@@ -7,6 +7,7 @@ basedir=`dirname "$scriptpath"`
basedir
=
`
dirname
"
$basedir
"
`
wordlistfile
=
$(
realpath
$basedir
/wordlist.aspell
)
branch
=
"origin/
${
CI_MERGE_REQUEST_TARGET_BRANCH_NAME
:-
preview
}
"
files_to_skip
=(
doc.zih.tu-dresden.de/docs/accessibility.md doc.zih.tu-dresden.de/docs/data_protection_declaration.md data_protection_declaration.md
)
aspellmode
=
if
aspell dump modes |
grep
-q
markdown
;
then
aspellmode
=
"--mode=markdown"
...
...
@@ -14,9 +15,10 @@ fi
function
usage
()
{
cat
<<-
EOF
usage:
$0
[file]
usage:
$0
[file
| -a
]
If file is given, outputs all words of the file, that the spell checker cannot recognize.
If file is omitted, checks whether any changed file contains more unrecognizable words than before the change.
If parameter -a (or --all) is given instead of the file, checks all markdown files.
Otherwise, checks whether any changed file contains more unrecognizable words than before the change.
If you are sure a word is correct, you can put it in
$wordlistfile
.
EOF
}
...
...
@@ -29,12 +31,52 @@ function getNumberOfAspellOutputLines(){
getAspellOutput |
wc
-l
}
function
isMistakeCountIncreasedByChanges
(){
any_fails
=
false
function
isWordlistSorted
(){
#Unfortunately, sort depends on locale and docker does not provide much.
#Therefore, it uses bytewise comparison. We avoid problems with the command tr.
if
!
sed
1d
"
$wordlistfile
"
|
tr
[
:upper:]
[
:lower:] |
sort
-C
;
then
return
1
fi
return
0
}
function
shouldSkipFile
(){
printf
'%s\n'
"
${
files_to_skip
[@]
}
"
|
grep
-xq
$1
}
function
checkAllFiles
(){
any_fails
=
false
if
isWordlistSorted
;
then
echo
"Unsorted wordlist in
$wordlistfile
"
any_fails
=
true
fi
files
=
$(
git ls-tree
--full-tree
-r
--name-only
HEAD
$basedir
/ |
grep
.md
)
while
read
file
;
do
if
[
"
${
file
:
-3
}
"
==
".md"
]
;
then
if
shouldSkipFile
${
file
}
;
then
echo
"Skip
$file
"
else
echo
"Check
$file
"
echo
"-- File
$file
"
if
{
cat
"
$file
"
| getAspellOutput |
tee
/dev/fd/3 |
grep
-xq
'.*'
;
}
3>&1
;
then
any_fails
=
true
fi
fi
fi
done
<<<
"
$files
"
if
[
"
$any_fails
"
==
true
]
;
then
return
1
fi
return
0
}
function
isMistakeCountIncreasedByChanges
(){
any_fails
=
false
if
isWordlistSorted
;
then
echo
"Unsorted wordlist in
$wordlistfile
"
any_fails
=
true
fi
...
...
@@ -48,9 +90,7 @@ function isMistakeCountIncreasedByChanges(){
while
read
oldfile
;
do
read
newfile
if
[
"
${
newfile
:
-3
}
"
==
".md"
]
;
then
if
[[
$newfile
==
*
"accessibility.md"
*
||
$newfile
==
*
"data_protection_declaration.md"
*
||
$newfile
==
*
"legal_notice.md"
*
]]
;
then
if
shouldSkipFile
${
newfile
:2
}
;
then
echo
"Skip
$newfile
"
else
echo
"Check
$newfile
"
...
...
@@ -90,6 +130,9 @@ if [ $# -eq 1 ]; then
usage
exit
;;
-a
|
--all
)
checkAllFiles
;;
*
)
cat
"
$1
"
| getAspellOutput
;;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment