mirror of
https://github.com/dense-analysis/ale
synced 2024-12-14 02:15:43 +00:00
ed93cd1494
There were a couple of issues - `paste` requires a file argument - `mktemp` requires a pattern argument - `sort` doesn't support `-h`, but `-n` is enough for sorting on numbers, and `-s` was introduced to perform a stable sort instead. The main issues were that BSD `sed` does not support: - Alternation (`\|`) - solved by splitting to multiple patterns - Bound shortcuts (`x\+`, `x\?`) - solved by replacing with `xx*` and `x\{0,1\}` respectively - Lower-casing (`\L`) - solved by piping through `tr` instead (this will lowercase everything and not only the integration names, but I assumed that wasn't too much of an issue, as a portable alternative for the selective downcasing would be much more involved).
69 lines
2.0 KiB
Bash
Executable File
69 lines
2.0 KiB
Bash
Executable File
#!/bin/bash -eu
|
|
|
|
# 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/' \
|
|
)"
|
|
# -- shellcheck complains about expr, but it works better.
|
|
# shellcheck disable=SC2003
|
|
ale_help_end_line="$(expr "$ale_help_start_line" + "$ale_help_section_size")"
|
|
|
|
# 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/' \
|
|
)"
|
|
# shellcheck disable=SC2003
|
|
readme_end_line="$(expr "$readme_start_line" + "$readme_section_size")"
|
|
|
|
doc_file="$(mktemp -t doc.XXXXXXXX)"
|
|
readme_file="$(mktemp -t readme.XXXXXXXX)"
|
|
|
|
sed -n "$ale_help_start_line,$ale_help_end_line"p doc/ale.txt \
|
|
| grep '\* .*: ' \
|
|
| sed 's/^*//' \
|
|
| sed 's/[`!^]//g;s/([^)]*)//g' \
|
|
| sed 's/ *\([,:]\)/\1/g' \
|
|
| sed 's/ */ /g' \
|
|
| sed 's/^ *//;s/ *$//' \
|
|
| sed 's/^/ /' \
|
|
> "$doc_file"
|
|
|
|
sed -n "$readme_start_line,$readme_end_line"p README.md \
|
|
| grep '| .* |' \
|
|
| sed '/^| Language/d;/^| ---/d' \
|
|
| sed 's/^|//' \
|
|
| sed 's/ \{0,1\}|/:/' \
|
|
| sed 's/[`!^|]//g;s/([^)]*)//g' \
|
|
| sed 's/\[//g;s/\]//g' \
|
|
| sed 's/see[^,]*//g' \
|
|
| sed 's/ *\([,:]\)/\1/g' \
|
|
| sed 's/ */ /g' \
|
|
| sed 's/^ *//;s/ *$//' \
|
|
| 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"
|