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