[check] Filter programlistings for check-doc-syntax.sh
[cairo/haiku.git] / src / check-doc-syntax.sh
blob1f7cd2a0144cd3fc35995b77f20f1baff45794b5
1 #!/bin/sh
3 LANG=C
5 if ! grep --version 2>/dev/null | grep GNU >/dev/null; then
6 echo "GNU grep not found; skipping test"
7 exit 0
8 fi
10 test -z "$srcdir" && srcdir=.
11 status=0
13 echo Checking documentation for incorrect syntax
15 # Note: this test is also run from doc/public/ to check the SGML files
17 if test "x$SGML_DOCS" = x; then
18 FILES=`find "$srcdir" -name '*.h' -or -name '*.c' -or -name '*.cpp'`
21 # Note: This test reports false positives on non-gtk-doc comments and
22 # non-public enum values, (such as CAIRO_FIXED_FRAC_BITS in the comment
23 # for _cairo_output_stream_init). I'm opposed to uglifying those comments
24 # with % just to shut this warning up. So instead, I'm turning this check
25 # off. (cworth 2008-03-02)
27 # Meanwhile, I'd love to see a system that would just link things like
28 # enums up without any decoration.
30 #enum_regexp='\([^%@]\|^\)\<\(FALSE\|TRUE\|NULL\|CAIRO_[0-9A-Z_]*[^(0-9A-Z_]\)'
31 #if test "x$SGML_DOCS" = x; then
32 # enum_regexp='^[/ ][*] .*'$enum_regexp
33 #fi
34 #if grep "$enum_regexp" $FILES | grep -v '#####'; then
35 # status=1
36 # echo Error: some macros in the docs are not prefixed by percent sign.
37 # echo Fix this by searching for the following regexp in the above files:
38 # echo " '$enum_regexp'"
39 #fi
41 type_regexp='\( .*[^#]\| \|^\)\<cairo[0-9a-z_]*_t\>\($\|[^:]$\|[^:].\)'
42 if test "x$SGML_DOCS" = x; then
43 type_regexp='^[/ ][*]'$type_regexp
44 else
45 type_regexp='\(.'$type_regexp'\)\|\('$type_regexp'.\)'
48 # We need to filter out gtk-doc markup errors for program listings.
49 files=`grep "$type_regexp" $FILES | grep -v '#####' | cut -d: -f1 | sort | uniq`
50 if test -n "$files" && sed -e '/<programlisting>/,/<\/programlisting>/d' $files | grep "$type_regexp" | grep -v '#####'; then
51 status=1
52 echo Error: some type names in the docs are not prefixed by hash sign,
53 echo neither are the only token in the doc line followed by colon.
54 echo Fix this by searching for the following regexp in the above files:
55 echo " '$type_regexp'"
58 func_regexp='\([^#]\|^\)\<\(cairo_[][<>/0-9a-z_]*\> \?[^][ <>(]\)'
59 if test "x$SGML_DOCS" = x; then
60 func_regexp='^[/ ][*] .*'$func_regexp
63 # We need to filter out gtk-doc markup errors for program listings.
64 files=`grep "$func_regexp" $FILES | grep -v '#####' | cut -d: -f1 | sort | uniq`
65 if test -n "$files" && sed -e '/<programlisting>/,/<\/programlisting>/d' $files | grep "$func_regexp" | grep -v '#####'; then
66 status=1
67 echo Error: some function names in the docs are not followed by parentheses.
68 echo Fix this by searching for the following regexp in the above files:
69 echo " '$func_regexp'"
72 note_regexp='NOTE'
73 if grep "$note_regexp" $FILES; then
74 status=1
75 echo Error: some source files contain the string 'NOTE'.
76 echo Be civil and replace it by 'Note' please.
79 exit $status