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