Split Scriptable into a subdirectory.
[gemrb.git] / admin / check_gui_doc.pl
blob97aab19d8b2e6943f15fef7fd634b9bbb08ba83f
1 #!/usr/bin/perl -w
3 use strict;
4 use Digest::MD5 qw(md5_hex);
6 my $SRCFILE = "../gemrb/plugins/GUIScript/GUIScript.cpp";
7 my $TGTDIR = "../gemrb/docs/en/GUIScript";
9 my %fn_hash = ();
10 my %file_hash = ();
11 my %desc_hash = ();
13 my %file_ignore = (
14 'CVS' => 1,
15 'Makefile.am' => 1,
16 'Makefile.in' => 1,
17 'Makefile' => 1,
20 sub parse_guiscript_cpp {
21 local (*SRC);
23 my $fname = '';
24 my $desc = '';
26 open (SRC, "< $SRCFILE") || die "Can't open $SRCFILE: $!\n";
28 while (defined (my $line = <SRC>)) {
29 if ($line =~ /^PyDoc_STRVAR\s*\(\s*GemRB_(.*)__doc/g) {
30 $fname = $1;
32 elsif ($fname && $line =~ /^\"(.*)\"\s*$/g) {
33 $desc .= $1;
35 elsif ($fname && $line =~ /^\"(.*)\"\s*\);\s*$/g) {
36 $desc .= " : $1";
37 my $md5 = md5_hex ($1);
38 $fn_hash{$fname} = $md5;
39 $desc_hash{$fname} = $desc;
40 $fname = '';
41 $desc = '';
45 close (SRC);
48 sub parse_doc {
49 my ($file) = @_;
50 local (*SRC);
52 open (SRC, "< $TGTDIR/$file") || die "Can't open $TGTDIR/$file: $!\n";
54 my $md5 = '';
55 while (defined (my $line = <SRC>)) {
56 if ($line =~ /^MD5:\s*([0-9a-f]+)/o) {
57 $md5 = $1;
58 last;
62 $file_hash{$file} = $md5;
64 close (SRC);
67 &parse_guiscript_cpp ();
69 opendir (DIR, $TGTDIR) || die "Can't open dir $TGTDIR: $!\n";
70 my @files = grep { -f "$TGTDIR/$_" && ! exists ($file_ignore{$_}) } grep !/^\.\.?/, readdir (DIR);
71 closedir (DIR);
73 foreach my $f (@files) {
74 &parse_doc ($f);
77 foreach my $fn (sort keys %fn_hash) {
78 my $md5_1 = $fn_hash{$fn};
79 my $file = $fn . ".txt";
81 if (exists ($file_hash{$file})) {
82 my $md5_2 = $file_hash{$file};
84 if ($md5_1 eq $md5_2) {
85 print "= $fn\n";
86 } else {
87 print "! $fn: $md5_1 : $md5_2\n";
90 else {
91 print "+ $fn : $md5_1 : $desc_hash{$fn}\n";
95 foreach my $file (sort keys %file_hash) {
96 my $md5 = $file_hash{$file};
97 my $fn = $file;
98 $fn =~ s/\.[^\.]+$//o;
100 if (! exists ($fn_hash{$fn})) {
101 print "- $fn : $md5\n";