]> git.xonotic.org Git - xonotic/gmqcc.git/blob - misc/check-doc.sh
Merge branch 'master' of github.com:graphitemaster/gmqcc
[xonotic/gmqcc.git] / misc / check-doc.sh
1 #!/bin/sh
2 prog=$0
3
4 die() {
5         echo "$@"
6         exit 1
7 }
8
9 want() {
10         test -e "$1" && return
11         echo "$prog: missing $1"
12         echo "$prog: run this script from the top of a gmqcc source tree"
13         exit 1
14 }
15
16 for i in opts.def          \
17          doc/gmqcc.1       \
18          gmqcc.ini.example
19 do want "$i"; done
20
21 # y/_ABCDEFGHIJKLMNOPQRSTUVWXYZ/-abcdefghijklmnopqrstuvwxyz/;
22 check_opt() {
23         opt_def_name=$1
24         arg_char=$2
25
26         for i in $(sed -ne \
27         '/^#ifdef GMQCC_TYPE_'${opt_def_name}'$/,/^#endif/{
28                 /GMQCC_DEFINE_FLAG/{
29                         s/^.*GMQCC_DEFINE_FLAG(\([^,)]*\)[),].*$/\1/;p;
30                 }
31         }' opts.def)
32         do
33                 opt=$(echo "$i" | tr -- '_A-Z' '-a-z')
34                 grep -qF -- ".It Fl "${arg_char}" Ns Cm $opt" \
35                         doc/gmqcc.1 || echo "doc/gmqcc.1: missing: -${arg_char}$opt"
36                 grep -q -- "[^a-zA-Z_]$i[^a-zA-Z_]" \
37                         gmqcc.ini.example || echo "gmqcc.ini.example: missing: $i"
38         done
39 }
40
41 check_opt FLAGS f
42 check_opt WARNS W
43 check_opt OPTIMIZATIONS O
44
45 # TODO: linux version
46 if [ "$(uname -s)" != "Linux" ]; then
47     for i in doc/*.1;
48     do
49         mandoc -Tlint -Wall "$i";
50     done
51 fi