2018-05-01 08:18:03 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
2017-08-28 17:05:12 -04:00
|
|
|
|
|
|
|
# This script compares the table of supported tools in both the README file
|
|
|
|
# and the doc/ale.txt file, so we can complain if they don't match up.
|
|
|
|
|
|
|
|
# Find the start and end lines for the help section.
|
|
|
|
ale_help_start_line="$( \
|
|
|
|
grep -m1 -n '^[0-9][0-9]*\. *Supported Languages' doc/ale.txt \
|
|
|
|
| sed 's/\([0-9]*\).*/\1/' \
|
|
|
|
)"
|
|
|
|
ale_help_section_size="$( \
|
|
|
|
tail -n +"$ale_help_start_line" doc/ale.txt \
|
|
|
|
| grep -m1 -n '================' \
|
|
|
|
| sed 's/\([0-9]*\).*/\1/' \
|
|
|
|
)"
|
2017-08-29 12:00:09 -04:00
|
|
|
# -- shellcheck complains about expr, but it works better.
|
|
|
|
# shellcheck disable=SC2003
|
|
|
|
ale_help_end_line="$(expr "$ale_help_start_line" + "$ale_help_section_size")"
|
2017-08-28 17:05:12 -04:00
|
|
|
|
|
|
|
# Find the start and end lines for the same section in the README.
|
|
|
|
readme_start_line="$( \
|
|
|
|
grep -m1 -n '^.*[0-9][0-9]*\. *Supported Languages' README.md \
|
|
|
|
| sed 's/\([0-9]*\).*/\1/' \
|
|
|
|
)"
|
|
|
|
readme_section_size="$( \
|
|
|
|
tail -n +"$readme_start_line" README.md \
|
|
|
|
| grep -m1 -n '^##.*Usage' \
|
|
|
|
| sed 's/\([0-9]*\).*/\1/' \
|
|
|
|
)"
|
2017-08-29 12:00:09 -04:00
|
|
|
# shellcheck disable=SC2003
|
|
|
|
readme_end_line="$(expr "$readme_start_line" + "$readme_section_size")"
|
2017-08-28 17:05:12 -04:00
|
|
|
|
2017-10-22 04:42:36 -04:00
|
|
|
doc_file="$(mktemp -t doc.XXXXXXXX)"
|
|
|
|
readme_file="$(mktemp -t readme.XXXXXXXX)"
|
2017-08-28 17:05:12 -04:00
|
|
|
|
|
|
|
sed -n "$ale_help_start_line,$ale_help_end_line"p doc/ale.txt \
|
|
|
|
| grep '\* .*: ' \
|
|
|
|
| sed 's/^*//' \
|
2017-10-22 04:42:36 -04:00
|
|
|
| sed 's/[`!^]//g;s/([^)]*)//g' \
|
2017-08-28 17:05:12 -04:00
|
|
|
| sed 's/ *\([,:]\)/\1/g' \
|
|
|
|
| sed 's/ */ /g' \
|
2017-10-22 04:42:36 -04:00
|
|
|
| sed 's/^ *//;s/ *$//' \
|
2017-08-28 17:05:12 -04:00
|
|
|
| sed 's/^/ /' \
|
|
|
|
> "$doc_file"
|
|
|
|
|
|
|
|
sed -n "$readme_start_line,$readme_end_line"p README.md \
|
|
|
|
| grep '| .* |' \
|
2017-10-22 04:42:36 -04:00
|
|
|
| sed '/^| Language/d;/^| ---/d' \
|
2017-08-28 17:05:12 -04:00
|
|
|
| sed 's/^|//' \
|
2017-10-22 04:42:36 -04:00
|
|
|
| sed 's/ \{0,1\}|/:/' \
|
|
|
|
| sed 's/[`!^|]//g;s/([^)]*)//g' \
|
|
|
|
| sed 's/\[//g;s/\]//g' \
|
|
|
|
| sed 's/see[^,]*//g' \
|
2017-08-28 17:05:12 -04:00
|
|
|
| sed 's/ *\([,:]\)/\1/g' \
|
|
|
|
| sed 's/ */ /g' \
|
2017-10-22 04:42:36 -04:00
|
|
|
| sed 's/^ *//;s/ *$//' \
|
2017-08-28 17:05:12 -04:00
|
|
|
| sed 's/^/ /' \
|
|
|
|
| sed 's/ *-n flag//g' \
|
|
|
|
> "$readme_file"
|
|
|
|
|
|
|
|
exit_code=0
|
|
|
|
|
|
|
|
diff -U0 "$readme_file" "$doc_file" || exit_code=$?
|
|
|
|
|
|
|
|
rm "$doc_file"
|
|
|
|
rm "$readme_file"
|
|
|
|
|
|
|
|
exit "$exit_code"
|