diff options
author | Stefan Kost <stefkost@src.gnome.org> | 2007-08-12 10:06:54 +0000 |
---|---|---|
committer | Stefan Kost <stefkost@src.gnome.org> | 2007-08-12 10:06:54 +0000 |
commit | e3d22b5839fe39e7bfee67158c041c4612c87c15 (patch) | |
tree | f256b35d8d024e931b7393052cd5e0c5a9b9a0b6 /gtkdoc-check.in | |
parent | e0661c3bdcc0c9d89e11a614bb756f557e8e3526 (diff) | |
download | gtk-doc-e3d22b5839fe39e7bfee67158c041c4612c87c15.tar.gz |
Replacing my shell based test script by Davids perl based one. Add
* Makefile.am:
* configure.in:
* gtkdoc-check:
* gtkdoc-check.in:
Replacing my shell based test script by Davids perl based one. Add
licence, copyright and docs header. Integrate with build.
svn path=/trunk/; revision=471
Diffstat (limited to 'gtkdoc-check.in')
-rwxr-xr-x | gtkdoc-check.in | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/gtkdoc-check.in b/gtkdoc-check.in new file mode 100755 index 0000000..d98639d --- /dev/null +++ b/gtkdoc-check.in @@ -0,0 +1,96 @@ +#!@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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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) +############################################################################# + +my $DOC_MODULE; +my $checks = 3; + +# We like Makefile.am more but builddir does not necessarily contain one. +my $makefile = (-f 'Makefile.am') ? 'Makefile.am' : 'Makefile'; +$DOC_MODULE = &Grep('^\s*DOC_MODULE\s*=\s*(\S+)', $makefile, 'DOC_MODULE'); + +print "Running suite(s): gtk-doc-$DOC_MODULE\n"; + +my $undocumented = int &Grep('^(\d+)\s+not\s+documented\.\s*$', + "$DOC_MODULE-undocumented.txt", + 'number of undocumented symbols'); +my $incomplete = int &Grep('^(\d+)\s+symbols?\s+incomplete\.\s*$', + "$DOC_MODULE-undocumented.txt", + 'number of incomplete symbols'); +my $total = $undocumented + $incomplete; +if ($total) { + print "$DOC_MODULE-undocumented.txt:1:E: $total undocumented or incomplete symbols\n"; +} + +my $undeclared = &CheckEmpty("$DOC_MODULE-undeclared.txt", + 'undeclared symbols'); +my $unused = &CheckEmpty("$DOC_MODULE-unused.txt", + 'unused documentation entries'); + +my $failed = ($total > 0) + ($undeclared != 0) + ($unused != 0); +my $rate = 100.0*($checks - $failed)/$checks; +printf '%.1f%%: Checks %d, Failures: %d%s', $rate, $checks, $failed, "\n"; +exit ($failed != 0); + +sub Grep() { + my ($regexp, $filename, $what) = @_; + my $retval; + + if (not open GFILE, "<$filename") { + die "Cannot open $filename: $!\n"; + } + while (<GFILE>) { + 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 (<GFILE>) { + if (m/\S/) { + $count++ + } + } + close GFILE; + if ($count) { + print "$filename:1:E: $count $what\n" + } + return $count; +} + |