beta-0.89.2
[luatex.git] / source / libs / cairo / cairo-src / src / check-doc-syntax.sh
blob762a48429b0202c6c387e86bbf32090b8a2488e1
1 #!/bin/sh
3 LC_ALL=C
4 export LC_ALL
6 if grep --version 2>/dev/null | grep GNU >/dev/null; then
8 else
9 echo "GNU grep not found; skipping test"
10 exit 0
13 test -z "$srcdir" && srcdir=.
14 stat=0
16 echo Checking documentation for incorrect syntax
18 cd "$srcdir"
20 if test "x$SGML_DOCS" = x; then
21 FILES=$all_cairo_files
22 if test "x$FILES" = x; then
23 FILES=`find . -name 'cairo*.h' -or -name 'cairo*.c' -or -name 'cairo*.cpp'`
27 enum_regexp="\([^%@']\|^\)\<\(FALSE\|TRUE\|NULL\|CAIRO_[0-9A-Z_]*\)\($\|[^(A-Za-z0-9_]\)"
28 if test "x$SGML_DOCS" = x; then
29 enum_regexp='^[^:]*:[/ ][*]\(\|[ \t].*\)'$enum_regexp\($\|[^:]\)
31 if echo $FILES | xargs grep . /dev/null | sed -e '/<programlisting>/,/<\/programlisting>/d' | grep "$enum_regexp" | grep -v '#####'; then
32 stat=1
33 echo Error: some macros in the docs are not prefixed by percent sign.
34 echo Fix this by searching for the following regexp in the above files:
35 echo " '$enum_regexp'"
36 fi >&2
38 type_regexp="\( .*[^#']\| \|^\)\<cairo[0-9a-z_]*_t\>\($\|[^:]$\|[^:].\)"
39 if test "x$SGML_DOCS" = x; then
40 type_regexp='^[^:]*:[/ ][*]'$type_regexp
41 else
42 type_regexp='\(.'$type_regexp'\)\|\('$type_regexp'.\)'
45 if echo $FILES | xargs grep . /dev/null | sed -e '/<programlisting>/,/<\/programlisting>/d' | grep -v "@Title" | grep "$type_regexp" | grep -v '#####'; then
46 stat=1
47 echo Error: some type names in the docs are not prefixed by hash sign,
48 echo neither are the only token in the doc line followed by colon.
49 echo Fix this by searching for the following regexp in the above files:
50 echo " '$type_regexp'"
51 fi >&2
53 func_regexp="\([^#']\|^\)\<\(cairo_[][<>/0-9a-z_]*\>[^][<>(]\)"
54 if test "x$SGML_DOCS" = x; then
55 func_regexp='^[^:]*:[/ ][*]\(\|[ \t].*\)'$func_regexp
58 # We need to filter out gtk-doc markup errors for program listings.
59 if echo $FILES | xargs grep . /dev/null | sed -e '/<programlisting>/,/<\/programlisting>/d' | grep "$func_regexp" | grep -v '^[^:]*: [*] [a-z_0-9]*:$' | grep -v '#####'; then
60 stat=1
61 echo Error: some function names in the docs are not followed by parentheses.
62 echo Fix this by searching for the following regexp in the above files:
63 echo " '$func_regexp'"
64 fi >&2
66 note_regexp='\<NOTE\>'
67 if echo $FILES | xargs grep "$note_regexp" /dev/null; then
68 stat=1
69 echo Error: some source files contain the string 'NOTE'.
70 echo Be civil and replace it by 'Note' please.
71 fi >&2
73 # Only run the syntax checker on the source files (not doc/)
74 if test -e ./check-doc-syntax.awk; then
75 if echo $FILES | xargs awk -f ./check-doc-syntax.awk ; then
77 else
78 stat=1
79 fi >&2
82 exit $stat