2 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # Check that options are documented in the manpages of the tool.
17 # Usage: check_manpages from to
22 for bin
in bin
/nit
*; do
26 manc
=share
/man
/nitc.md
27 man
=share
/man
/$name.md
29 if ! test -f
$man; then
30 echo "No manpage for binary $bin. Add one in $man"
36 $bin --help |
grep '^ ' |
sed 's/ */;/;s/ //' > check_manpages
-option_list.out
37 while IFS
=';' read opt cmt
; do
38 # Generate first lines for the man page from --help
39 printf "%s\n" "$opt" |
sed 's/, /`, `/g;s/^/### `/;s/$/`/' > check_manpages
-from_help.out
40 echo "$cmt." >> check_manpages
-from_help.out
42 # Generate grep pattern to search in the existing manpage
43 printf "%s\n" "$opt" |
sed 's/, /`\\|`/g;s/^/###.*\\(`/;s/$/`\\)/' > check_manpages
-grep_pattern.out
46 if ! grep -A
1 -f check_manpages
-grep_pattern.out
$man > check_manpages
-from_man.out
; then
47 if ! grep -A
1 -f check_manpages
-grep_pattern.out
$manc > check_manpages
-from_man.out
; then
49 echo "$opt: missing in the manpage $man. Here what is expected:"
51 cat check_manpages
-from_help.out
57 # found in `nitc.md`, check more only if dealing with nitc
58 [ "$man" = "$manc" ] ||
continue
61 # Test what is expected
62 if ! diff -q
<(sed 's/\s*(.*)//' check_manpages
-from_help.out
) <(sed 's/\s*(.*)//' check_manpages
-from_man.out
) > /dev
/null
; then
63 echo "$opt: mismatch documentation in the manpage $man. Here the word diff:"
65 wdiff check_manpages
-from_help.out check_manpages
-from_man.out | colordiff
70 done < check_manpages
-option_list.out