diff options
Diffstat (limited to '')
-rwxr-xr-x | scripts/assert-content.sh | 25 | ||||
-rwxr-xr-x | scripts/assert-nixfmt.sh | 16 | ||||
-rwxr-xr-x | scripts/assert-shellcheck.sh | 6 | ||||
-rwxr-xr-x | scripts/assert-spelling.sh | 36 | ||||
-rwxr-xr-x | scripts/assert-todos.sh | 12 | ||||
-rw-r--r-- | scripts/publish-env.sh | 4 | ||||
-rw-r--r-- | scripts/spelling/en.txt (renamed from spelling/en.txt) | 0 | ||||
-rw-r--r-- | scripts/spelling/fr.txt (renamed from spelling/fr.txt) | 0 | ||||
-rw-r--r-- | scripts/spelling/international.txt (renamed from spelling/international.txt) | 0 | ||||
-rw-r--r-- | scripts/spelling/pt.txt (renamed from spelling/pt.txt) | 1 |
10 files changed, 79 insertions, 21 deletions
diff --git a/scripts/assert-content.sh b/scripts/assert-content.sh index a0d661f..e694580 100755 --- a/scripts/assert-content.sh +++ b/scripts/assert-content.sh @@ -8,23 +8,8 @@ red() { echo -e "${red}${1}${end}"; } ## Constant definitions -JSON="${1:-}" -[[ -z "${JSON}" ]] && { - red 'Missing input JSON file.' - cat <<EOF -Usage: - $0 <SITE_JSON_PATH> - - Arguments - SITE_JSON_PATH Path to the site.json file which contains data and metadata about pages of the site. - -Examples: - $0 _site/site.json - $0 result/site.json - $0 \$(nix-build -A subtasks.docs)/site.json -EOF - exit 2 -} +jekyll build +JSON='_site/site.json' LANGS=(en pt fr) IGNORED_PAGES=(site.json sitemap.xml *.atom) @@ -138,6 +123,11 @@ for til in $(jq -r '.tils[] | @base64' "${JSON}"); do assert-frontmatter "$til" 'post' '_tils' done +echo Linting slides... >&2 +for slide in $(jq -r '.slides[] | @base64' "${JSON}"); do + assert-frontmatter "$slide" 'post' '_slides' +done + echo Asserting unique refs... >&2 KNOWN_IDS=() assert-unique-ref() { @@ -163,5 +153,6 @@ assert-unique-ref() { assert-unique-ref "$(jq -r '.pages[] | @base64' "${JSON}")" assert-unique-ref "$(jq -r '.articles[] | @base64' "${JSON}")" assert-unique-ref "$(jq -r '.tils[] | @base64' "${JSON}")" +assert-unique-ref "$(jq -r '.slides[] | @base64' "${JSON}")" echo Done. >&2 diff --git a/scripts/assert-nixfmt.sh b/scripts/assert-nixfmt.sh new file mode 100755 index 0000000..7a68fa9 --- /dev/null +++ b/scripts/assert-nixfmt.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" +cd ../ + +format() { + nix_file="${1}" + diff <(nixfmt < "${nix_file}") "${nix_file}" || { + echo "The file '${nix_file}' is unformatted. To fix it, run:" + echo " nixfmt ${nix_file}" + exit 1 + } +} +export -f format + +find . -type f -name '*.nix' -print0 | xargs -0 -I% bash -c "format %" diff --git a/scripts/assert-shellcheck.sh b/scripts/assert-shellcheck.sh new file mode 100755 index 0000000..e24c29c --- /dev/null +++ b/scripts/assert-shellcheck.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" +cd ../ + +git ls-files | grep '\.sh$' | xargs shellcheck diff --git a/scripts/assert-spelling.sh b/scripts/assert-spelling.sh new file mode 100755 index 0000000..caaecfa --- /dev/null +++ b/scripts/assert-spelling.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" +cd ../ + +export LANG=C.UTF-8 + +for DICT in scripts/spelling/*.txt; do + diff <(sort "$DICT") "$DICT" || { + echo "The $DICT dictionary is unsorted. To fix it, run:" >&2 + echo " LANG=C.UTF-8 sort docs/$DICT | sponge docs/$DICT" >&2 + exit 1 + } +done + +OUT="$(mktemp)" +shopt -s globstar +jekyll build +for f in _site/**/*.html; do + if ! grep -E '^_site/pastebin' <(echo "$f") > /dev/null; then + if ! grep -E '^_site/vendor/' <(echo "$f") > /dev/null; then + l="$(head -n2 "$f" | tail -n1 | cut -d\" -f2)" + hunspell -u3 -H -d "$l" -p <(cat scripts/spelling/international.txt "scripts/spelling/$l.txt") "$f" | tee -a "$OUT" + fi + fi +done + +if [[ -s "$OUT" ]]; then + printf "\nvvv Mispelled words detected by hunspell.\n\n" + sort < "$OUT" | uniq + printf "\n^^^\n" >&2 + exit 1 +else + echo "No spelling errors detected" + exit 0 +fi diff --git a/scripts/assert-todos.sh b/scripts/assert-todos.sh new file mode 100755 index 0000000..a59b4cd --- /dev/null +++ b/scripts/assert-todos.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" +cd ../ + +# shellcheck disable=2046 +if grep -R FIXME $(git ls-files) | \ + grep -Ev '^(vendor/|.git/|scripts/assert-todos.sh|templates)'; then + echo "Found dangling FIXME markers on the project." + echo "You should write them down properly on TODOs.org." + exit 1 +fi diff --git a/scripts/publish-env.sh b/scripts/publish-env.sh deleted file mode 100644 index d5e8be2..0000000 --- a/scripts/publish-env.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -export SERVER_URL=root@euandre.org -export DOCS_SERVER_PATH="/home/user-data/www/default/" diff --git a/spelling/en.txt b/scripts/spelling/en.txt index bebfc76..bebfc76 100644 --- a/spelling/en.txt +++ b/scripts/spelling/en.txt diff --git a/spelling/fr.txt b/scripts/spelling/fr.txt index aa09184..aa09184 100644 --- a/spelling/fr.txt +++ b/scripts/spelling/fr.txt diff --git a/spelling/international.txt b/scripts/spelling/international.txt index 3536249..3536249 100644 --- a/spelling/international.txt +++ b/scripts/spelling/international.txt diff --git a/spelling/pt.txt b/scripts/spelling/pt.txt index 2befc17..65d4ac8 100644 --- a/spelling/pt.txt +++ b/scripts/spelling/pt.txt @@ -23,6 +23,7 @@ achar arquivo artigos buscar +categoria chegar comece comentário |