All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
6 # This script checks that the table of contents for the supported tools is
7 # sorted, and that the table matches the files.
9 toc_section_start_line="$(
10 grep -m1 -n '^7\..*\*ale-other-integration-options\*' doc/ale.txt \
11 | sed 's/\([0-9]*\).*/\1/' \
13 toc_start_offset="$( \
14 tail -n +"$toc_section_start_line" doc/ale.txt \
15 | grep -m1 -n '^ .*\.\.\.' \
16 | sed 's/\([0-9]*\).*/\1/' \
18 # shellcheck disable=SC2003
19 toc_start_line="$(expr "$toc_section_start_line" + "$toc_start_offset" - 1)"
20 toc_section_size="$( \
21 tail -n +"$toc_start_line" doc/ale.txt \
22 | grep -m1 -n '^===*$' \
23 | sed 's/\([0-9]*\).*/\1/' \
25 # shellcheck disable=SC2003
26 toc_end_line="$(expr "$toc_start_line" + "$toc_section_size" - 4)"
28 toc_file="$(mktemp -t table-of-contents.XXXXXXXX)"
29 heading_file="$(mktemp -t headings.XXXXXXXX)"
30 tagged_toc_file="$(mktemp -t ale.txt.XXXXXXXX)"
31 sorted_toc_file="$(mktemp -t sorted-ale.txt.XXXXXXXX)"
33 sed -n "$toc_start_line,$toc_end_line"p doc/ale.txt \
34 | sed 's/^ \( *[^.][^.]*\)\.\.*|\(..*\)|/\1, \2/' \
37 # Get all of the doc files in a natural sorted order.
38 doc_files="$(/usr/bin/env ls -1v doc | grep '^ale-' | sed 's/^/doc\//' | paste -sd ' ' -)"
40 # shellcheck disable=SC2086
41 grep -h '\*ale-.*-options\|^[a-z].*\*ale-.*\*$' $doc_files \
43 | sed 's/ALE Shell Integration/ALE sh Integration/' \
44 | sed 's/ALE BibTeX Integration/ALE bib Integration/' \
45 | sed 's/ ALE \(.*\) Integration/\1/' \
46 | sed 's/ *\*\(..*\)\*$/, \1/' \
47 | tr '[:upper:]' '[:lower:]' \
48 | sed 's/objective-c/objc/' \
56 # Prefix numbers to table of contents entries so that sections aren't mixed up
57 # with sub-sections when they are sorted.
59 if [[ "$REPLY" =~ ^\ ]]; then
60 if ! ((in_section)); then
61 let section_index='section_index + 1'
65 if ((in_section)); then
66 let section_index='section_index + 1'
71 echo "$section_index $REPLY" >> "$tagged_toc_file"
74 # Sort the sections and sub-sections and remove the tags.
75 sort -sn "$tagged_toc_file" | sed 's/[0-9][0-9]* //' > "$sorted_toc_file"
77 echo 'Check for bad ToC sorting:'
79 diff -U2 "$sorted_toc_file" "$toc_file" || exit_code=$?
81 echo 'Check for mismatched ToC and headings:'
83 diff -U3 "$toc_file" "$heading_file" || exit_code=$?