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";
|
2000-06-05 17:51:24 +08:00
|
|
|
include("doc/prog-head.sgml");
|
2000-05-06 01:14:44 +08:00
|
|
|
process("");
|
2000-06-05 17:51:24 +08:00
|
|
|
include("doc/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 @_;
|
2000-06-05 17:51:24 +08:00
|
|
|
open(IN, "$srcdir/$f") || die "Unable to find $f";
|
2000-05-31 19:29:56 +08:00
|
|
|
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-06-03 01:23:53 +08:00
|
|
|
print OUT "<chapt>$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";
|
2000-06-05 17:51:24 +08:00
|
|
|
include("$dir/$arg");
|
2000-05-06 01:14:44 +08:00
|
|
|
} else { die "Unknown command: $cmd"; }
|
|
|
|
}
|
|
|
|
}
|