#!@PERL@ -w # -*- cperl -*- # # gtk-doc - GTK DocBook documentation generator. # Copyright (C) 2007 David Nečas # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################# # Script : gtkdoc-check # Description : Runs various checks on built documentation and outputs test # results. Can be run druring make check, by adding this to the # documentations Makefile.am: TESTS = $(GTKDOC_CHECK) ############################################################################# use strict; use Getopt::Long; my $PRINT_VERSION; my $PRINT_HELP; my %optctl = ('version' => \$PRINT_VERSION, 'help' => \$PRINT_HELP); GetOptions(\%optctl, "version", "help"); if ($PRINT_VERSION) { print "@VERSION@\n"; exit 0; } if ($PRINT_HELP) { print < 0) + ($undeclared != 0) + ($unused != 0) + ($missing_includes != 0); my $rate = 100.0*($checks - $failed)/$checks; printf "%.1f%%: Checks %d, Failures: %d\n", $rate, $checks, $failed; exit ($failed != 0); sub Grep() { my ($regexp, $filename, $what) = @_; my $retval; if (not open GFILE, "<$filename") { die "Cannot open $filename: $!\n"; } while () { next if not m/$regexp/; $retval = $1; last; } close GFILE; if (not defined $retval) { die "Cannot find $what in $filename\n"; } return $retval; } sub CheckEmpty() { my ($filename, $what) = @_; my $count = 0; if (not open GFILE, "<$filename") { return $count; } while () { if (m/\S/) { $count++ } } close GFILE; if ($count) { print "$filename:1:E: $count $what\n" } return $count; } sub CheckIncludes() { my ($main_sgml_file) = @_; if (not open GFILE, "<$main_sgml_file") { die "Cannot open $main_sgml_file: $!\n"; } # Check that each of the XML files in the xml directory are included in $DOC_MAIN_SGML_FILE my @xml_files = ; my $num_missing = 0; foreach my $xml_file (@xml_files) { my $regex = quotemeta ($xml_file); my $found = 0; while () { next if not m/"$regex"/; $found = 1; last; } if (!$found) { $num_missing++; print "$main_sgml_file doesn't appear to include \"$xml_file\"\n"; } seek (GFILE, 0, 0); } close (GFILE); return $num_missing; }