2000-05-06 01:14:44 +08:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
$srcdir = $ARGV[0];
|
|
|
|
|
2000-05-31 19:29:56 +08:00
|
|
|
open(OUT, ">prog.sgml") || die "Cannot create output file";
|
|
|
|
include("prog-head.sgml");
|
2000-05-06 01:14:44 +08:00
|
|
|
process("");
|
2000-05-31 19:29:56 +08:00
|
|
|
include("prog-foot.sgml");
|
2000-05-06 01:14:44 +08:00
|
|
|
close OUT;
|
|
|
|
exit 0;
|
|
|
|
|
2000-05-31 19:29:56 +08:00
|
|
|
sub include {
|
|
|
|
my $f = shift @_;
|
|
|
|
open(IN, "$srcdir/doc/$f") || die "Unable to find $f";
|
|
|
|
while (<IN>) {
|
|
|
|
print OUT;
|
|
|
|
}
|
|
|
|
close IN;
|
|
|
|
}
|
|
|
|
|
2000-05-06 01:14:44 +08:00
|
|
|
sub process {
|
|
|
|
my $dir = shift @_;
|
|
|
|
print "$dir/Doc\n";
|
|
|
|
open(IN, "$srcdir/$dir/Doc") || die "Unable to read $dir/Doc";
|
|
|
|
my @docfile = <IN>;
|
|
|
|
close IN;
|
|
|
|
foreach $_ (@docfile) {
|
|
|
|
chomp;
|
|
|
|
/^#/ && next;
|
2000-05-31 19:29:56 +08:00
|
|
|
/^([A-Z]+)\s*(.*)/ || die "Parse error: $_";
|
|
|
|
$cmd = $1;
|
|
|
|
$arg = $2;
|
2000-05-06 01:14:44 +08:00
|
|
|
if ($cmd eq "C") { process("$dir/$arg"); }
|
|
|
|
elsif ($cmd eq "H") {
|
|
|
|
push @stack, "H";
|
2000-05-31 19:29:56 +08:00
|
|
|
print OUT "<sect>$arg\n";
|
2000-05-06 01:14:44 +08:00
|
|
|
} elsif ($cmd eq "S") {
|
|
|
|
print " $arg\n";
|
2000-05-31 19:29:56 +08:00
|
|
|
open(DOC, "cd $srcdir/$dir ; $srcdir/doc/kernel-doc -bird $arg |") || die "Unable to start kernel-doc";
|
|
|
|
while (<DOC>) { print OUT; }
|
2000-05-06 01:14:44 +08:00
|
|
|
close DOC;
|
2000-05-31 19:29:56 +08:00
|
|
|
} elsif ($cmd eq "D") {
|
|
|
|
print " $arg\n";
|
|
|
|
include($arg);
|
2000-05-06 01:14:44 +08:00
|
|
|
} else { die "Unknown command: $cmd"; }
|
|
|
|
}
|
|
|
|
}
|