The twelfth batch
[git.git] / Documentation / lint-manpages.sh
blob92cfc0a15abd56a02faaae0d1bf651bf9017bccb
1 #!/bin/sh
3 extract_variable () {
5 cat ../Makefile
6 cat <<EOF
7 print_variable:
8 @\$(foreach b,\$($1),echo XXX \$(b:\$X=) YYY;)
9 EOF
10 ) |
11 make -C .. -f - print_variable 2>/dev/null |
12 sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p'
15 check_missing_docs () (
16 ret=0
18 for v in $ALL_COMMANDS
20 case "$v" in
21 git-merge-octopus) continue;;
22 git-merge-ours) continue;;
23 git-merge-recursive) continue;;
24 git-merge-resolve) continue;;
25 git-merge-subtree) continue;;
26 git-fsck-objects) continue;;
27 git-init-db) continue;;
28 git-remote-*) continue;;
29 git-stage) continue;;
30 git-legacy-*) continue;;
31 git-?*--?* ) continue ;;
32 esac
34 if ! test -f "$v.txt"
35 then
36 echo "no doc: $v"
37 ret=1
40 if ! sed -e '1,/^### command list/d' -e '/^#/d' ../command-list.txt |
41 grep -q "^$v[ ]"
42 then
43 case "$v" in
44 git)
47 echo "no link: $v"
48 ret=1
50 esac
52 done
54 exit $ret
57 check_extraneous_docs () {
59 sed -e '1,/^### command list/d' \
60 -e '/^#/d' \
61 -e '/guide$/d' \
62 -e '/interfaces$/d' \
63 -e 's/[ ].*//' \
64 -e 's/^/listed /' ../command-list.txt
65 make print-man1 |
66 grep '\.txt$' |
67 sed -e 's|^|documented |' \
68 -e 's/\.txt//'
69 ) | (
70 all_commands="$(printf "%s " "$ALL_COMMANDS" "$BUILT_INS" "$EXCLUDED_PROGRAMS" | tr '\n' ' ')"
71 ret=0
73 while read how cmd
75 case " $all_commands " in
76 *" $cmd "*) ;;
78 echo "removed but $how: $cmd"
79 ret=1;;
80 esac
81 done
83 exit $ret
87 BUILT_INS="$(extract_variable BUILT_INS)"
88 ALL_COMMANDS="$(extract_variable ALL_COMMANDS)"
89 EXCLUDED_PROGRAMS="$(extract_variable EXCLUDED_PROGRAMS)"
91 findings=$(
92 if ! check_missing_docs
93 then
94 ret=1
97 if ! check_extraneous_docs
98 then
99 ret=1
102 exit $ret
104 ret=$?
106 printf "%s" "$findings" | sort
108 exit $ret