summaryrefslogtreecommitdiff
path: root/scripts/doc-check
diff options
context:
space:
mode:
authorJoey Hess <joeyh@debian.org>2005-10-07 19:51:38 +0000
committerJoey Hess <joeyh@debian.org>2005-10-07 19:51:38 +0000
commit1ea73eea5ecc6a8ed901316049259aee737ee554 (patch)
tree03a077f0b1b1548f3c806bd1c5795964fba0fb52 /scripts/doc-check
downloadinstallation-guide-1ea73eea5ecc6a8ed901316049259aee737ee554.zip
move manual to top-level directory, split out of debian-installer package
Diffstat (limited to 'scripts/doc-check')
-rwxr-xr-xscripts/doc-check119
1 files changed, 119 insertions, 0 deletions
diff --git a/scripts/doc-check b/scripts/doc-check
new file mode 100755
index 000000000..83bea7ad9
--- /dev/null
+++ b/scripts/doc-check
@@ -0,0 +1,119 @@
+#!/usr/bin/perl -w
+
+# This script checks if the translations of the documents are up to date.
+# When called with "-d" option, it also prints what has changed in the
+# original since last translation.
+# If the "-r" option is used with the "-d" option, the diff will be taken
+# against the revision number specified with the -r option instead of
+# the latest revision of the English original.
+# When called with "-s" option, it also shows all files that are marked
+# untranslated.
+
+# SYNOPSIS:
+# ./doc-check [-d] [-r <revision>] [-s] [-v] [-V] [lang]
+#
+# (uses $lang set below if lang is not given on commandline)
+
+use Getopt::Std;
+use File::Find;
+$opt_d = $opt_r = $opt_s = $opt_v = $opt_V = 0;
+getopts('r:dsvV');
+# You may set this to your default language code
+$lang = shift || "pl";
+if ($opt_r and $opt_r !~ /[0-9]+/) {
+ warn "Please enter a revision number for parameter -r.\n";
+ exit 1
+}
+
+sub checkdiff
+{
+ my ($plfname, $enfname) = (@_);
+ my ($plrev, $enrev, $untrans) = getrev($plfname, $enfname);
+ $plrev and $enrev or return;
+ if ( "$plrev" ne "$enrev" ) {
+ if ($opt_d and $opt_r and $opt_r < $enrev) {
+ $enrev = $opt_r;
+ }
+ if ($untrans) {
+ print "$enfname : $plrev -> $enrev (untranslated)\n";
+ } else {
+ print "$enfname : $plrev -> $enrev\n";
+ }
+ if ($opt_d) {
+ my $s = "svn diff -r $plrev:$enrev $enfname";
+ warn "running $s:\n" if ($opt_V);
+ system($s);
+ }
+ } else {
+ if ($untrans && $opt_s) {
+ print "$plfname: untranslated\n";
+ }
+ }
+}
+
+sub getrev
+{
+ my ($plfname, $enfname) = (@_);
+ my ($plrev, $enrev, $untrans, $notconverted) = (0, 0, 0, 0);
+
+ warn "checking $plfname:\n" if $opt_v;
+ open FILE, $plfname or warn "$plfname: $!\n" and return;
+ while (<FILE>) {
+ if (/<!--\s*original version\D*([\d\.]+)\s*-->/) {
+ $plrev = $1;
+ last;
+ }
+ if (/<!--\s*original version\D*(\d+)\s*untranslated\s*-->/) {
+ $plrev = $1;
+ $untrans = 1;
+ last;
+ }
+ # Also check for revision comments of original documents
+ if (/<!--\s*\$Id: \S+ (\d+) /) {
+ $plrev = $1;
+ $notconverted = 1;
+ $untrans = 1;
+ last;
+ }
+ # Also support CVS style revision comments (depreciated)
+ if (/<!--\s*original document: en\/\S+, revision ([\d\.]+)\s*-->/) {
+ $plrev = $1;
+ last;
+ }
+ }
+ warn "checking $enfname:\n" if $opt_v;
+ open FILE, $enfname or warn "$enfname: $!\n" and return;
+ while (<FILE>) {
+ if (/\$Id: \S+ (\d+) /) {
+ $enrev = $1;
+ last;
+ }
+ # Also support CVS style revision comments (depreciated)
+ if (/\$Revision: (\d+) \$/) {
+ $enrev = $1;
+ last;
+ }
+ }
+ close FILE;
+ warn "failed to find revision for $plfname\n" unless $plrev;
+ warn "failed to find revision for $enfname\n" unless $enrev;
+ if ($notconverted) {
+ warn "$plfname: contains revision comment for original document\n";
+ warn " use 'rev-update' to convert\n";
+ }
+ return ($plrev, $enrev, $untrans);
+}
+
+sub process
+{
+ my $enfname = $File::Find::name;
+ return unless $enfname =~ m/\.xml$/;
+ my $plfname = $enfname;
+ $plfname =~ s,^en/,$lang/,;
+ checkdiff($plfname, $enfname);
+}
+File::Find::find({ wanted => \&process, no_chdir => 1 }, 'en');
+#checkdiff("build/install.$lang.xml", "build/install.en.xml");
+#checkdiff("release-notes.$lang.sgml","release-notes.sgml");
+#checkdiff("index.$lang.html.m4","index.en.html.m4");
+#checkdiff("dselect-beginner.$lang.sgml","dselect-beginner.sgml");