Debian Codegraph @

.sphinx/.markdownlint/doc-lint.sh

raw
1 #!/bin/sh -eu
2
3 if ! command -v mdl >/dev/null; then
4 echo "Install mdl with 'snap install mdl' first."
5 exit 1
6 fi
7
8 trap "rm -rf .tmp/" EXIT
9
10 ## Preprocessing
11
12 for fn in $(find doc/ -name '*.md'); do
13 mkdir -p $(dirname ".tmp/$fn");
14 sed -E "s/(\(.+\)=)/\1\n/" $fn > .tmp/$fn;
15 done
16
17 mdl .tmp/doc -s.sphinx/.markdownlint/style.rb -u.sphinx/.markdownlint/rules.rb --ignore-front-matter > .tmp/errors.txt || true
18
19 if [ ! -s ".tmp/errors.txt" ]; then
20 echo "Passed!"
21 exit 0
22 fi
23
24 ## Postprocessing
25
26 filtered_errors="$(grep -vxFf .sphinx/.markdownlint/exceptions.txt .tmp/errors.txt)"
27 if [ "$(echo "$filtered_errors" | wc -l)" = "2" ]; then
28 echo "Passed!"
29 exit 0
30 else
31 echo "Failed!"
32 echo "$filtered_errors"
33 exit 1
34 fi