This file is indexed.

/usr/bin/gtkdoc-check is in gtk-doc-tools 1.25-1ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/usr/bin/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 "1.25\n";
    exit 0;
}

if ($PRINT_HELP) {
    print <<EOF;
gtkdoc-check version 1.25 - run documentation unit tests

--version               Print the version of this program
--help                  Print this help
EOF
    exit 0;
}

my $checks = 4;

# Get parameters from test env, if not there try to grab them from the makefile
# We like Makefile.am more but builddir does not necessarily contain one.
my $makefile = (-f 'Makefile.am') ? 'Makefile.am' : 'Makefile';

# For historic reasons tests are launched in srcdir
my $SRCDIR = $ENV{"SRCDIR"};
my $BUILDDIR = $ENV{"BUILDDIR"};
my $dir = ".";
if (defined($BUILDDIR) and $BUILDDIR ne "") {
    $dir=$BUILDDIR;
}

# debug
#for my $key (sort(keys(%ENV))) { print "$key = ", $ENV{$key}, "\n"; }
# debug

my $DOC_MODULE = $ENV{"DOC_MODULE"};
if (!defined($DOC_MODULE) or $DOC_MODULE eq "") {
    $DOC_MODULE = &Grep('^\s*DOC_MODULE\s*=\s*(\S+)', $makefile, 'DOC_MODULE');
}
my $DOC_MAIN_SGML_FILE = $ENV{"DOC_MAIN_SGML_FILE"};
if (!defined($DOC_MAIN_SGML_FILE) or $DOC_MAIN_SGML_FILE eq "") {
    $DOC_MAIN_SGML_FILE = &Grep('^\s*DOC_MAIN_SGML_FILE\s*=\s*(\S+)', $makefile, 'DOC_MAIN_SGML_FILE');
    $DOC_MAIN_SGML_FILE =~ s/\$\(DOC_MODULE\)/$DOC_MODULE/;
}

print "Running suite(s): gtk-doc-$DOC_MODULE\n";

my $undocumented = int &Grep('^(\d+)\s+not\s+documented\.\s*$',
                             "$dir/$DOC_MODULE-undocumented.txt",
                             'number of undocumented symbols');
my $incomplete = int &Grep('^(\d+)\s+symbols?\s+incomplete\.\s*$',
                           "$dir/$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("$dir/$DOC_MODULE-undeclared.txt",
                             'undeclared symbols');
my $unused = &CheckEmpty("$dir/$DOC_MODULE-unused.txt",
                         'unused documentation entries');

my $missing_includes = &CheckIncludes ("$dir/$DOC_MAIN_SGML_FILE");

my $failed = ($total > 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 (<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;
}

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 = <xml/*.xml>;
    my $num_missing = 0;

    foreach my $xml_file (@xml_files) {
        my $regex = quotemeta ($xml_file);
        my $found = 0;

        while (<GFILE>) {
            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;
}