2007-04-06 07:17:20 +02:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
use File::Compare qw(compare);
|
2007-01-19 01:02:13 +01:00
|
|
|
|
|
|
|
sub format_one {
|
2007-11-09 02:21:48 +01:00
|
|
|
my ($out, $nameattr) = @_;
|
|
|
|
my ($name, $attr) = @$nameattr;
|
2007-01-19 01:02:13 +01:00
|
|
|
my ($state, $description);
|
2007-04-06 07:17:20 +02:00
|
|
|
$state = 0;
|
2007-01-19 01:02:13 +01:00
|
|
|
open I, '<', "$name.txt" or die "No such file $name.txt";
|
|
|
|
while (<I>) {
|
|
|
|
if (/^NAME$/) {
|
|
|
|
$state = 1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if ($state == 1 && /^----$/) {
|
|
|
|
$state = 2;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
next if ($state != 2);
|
|
|
|
chomp;
|
|
|
|
$description = $_;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
close I;
|
|
|
|
if (!defined $description) {
|
|
|
|
die "No description found in $name.txt";
|
|
|
|
}
|
|
|
|
if (my ($verify_name, $text) = ($description =~ /^($name) - (.*)/)) {
|
2007-12-29 07:20:38 +01:00
|
|
|
print $out "linkgit:$name\[1\]::\n\t";
|
2007-12-02 08:39:19 +01:00
|
|
|
if ($attr =~ / deprecated /) {
|
|
|
|
print $out "(deprecated) ";
|
2007-11-09 02:21:48 +01:00
|
|
|
}
|
|
|
|
print $out "$text.\n\n";
|
2007-01-19 01:02:13 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
die "Description does not match $name: $description";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my %cmds = ();
|
2007-12-02 08:39:19 +01:00
|
|
|
for (sort <>) {
|
2007-01-19 01:02:13 +01:00
|
|
|
next if /^#/;
|
|
|
|
|
|
|
|
chomp;
|
2007-11-09 02:21:48 +01:00
|
|
|
my ($name, $cat, $attr) = /^(\S+)\s+(.*?)(?:\s+(.*))?$/;
|
2007-12-02 08:39:19 +01:00
|
|
|
$attr = '' unless defined $attr;
|
|
|
|
push @{$cmds{$cat}}, [$name, " $attr "];
|
2007-01-19 01:02:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for my $cat (qw(ancillaryinterrogators
|
|
|
|
ancillarymanipulators
|
|
|
|
mainporcelain
|
|
|
|
plumbinginterrogators
|
|
|
|
plumbingmanipulators
|
2007-01-19 07:32:38 +01:00
|
|
|
synchingrepositories
|
|
|
|
foreignscminterface
|
|
|
|
purehelpers
|
|
|
|
synchelpers)) {
|
2007-01-19 01:02:13 +01:00
|
|
|
my $out = "cmds-$cat.txt";
|
|
|
|
open O, '>', "$out+" or die "Cannot open output file $out+";
|
|
|
|
for (@{$cmds{$cat}}) {
|
|
|
|
format_one(\*O, $_);
|
|
|
|
}
|
|
|
|
close O;
|
2007-04-06 07:17:20 +02:00
|
|
|
|
|
|
|
if (-f "$out" && compare("$out", "$out+") == 0) {
|
|
|
|
unlink "$out+";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print STDERR "$out\n";
|
|
|
|
rename "$out+", "$out";
|
|
|
|
}
|
2007-01-19 01:02:13 +01:00
|
|
|
}
|