Annotation of embedaddon/bird/tools/progdoc, revision 1.1.1.1

1.1       misho       1: #!/usr/bin/perl
                      2: 
                      3: $srcdir = $ARGV[0];
                      4: 
                      5: open(OUT, ">prog.sgml") || die "Cannot create output file";
                      6: include("doc/prog-head.sgml");
                      7: process("");
                      8: include("doc/prog-foot.sgml");
                      9: close OUT;
                     10: exit 0;
                     11: 
                     12: sub include {
                     13:   my $f = shift @_;
                     14:   open(IN, "$srcdir/$f") || die "Unable to find $f";
                     15:   while (<IN>) {
                     16:     print OUT;
                     17:   }
                     18:   close IN;
                     19: }
                     20: 
                     21: sub process {
                     22:   my $dir = shift @_;
                     23:   print "$dir/Doc\n";
                     24:   open(IN, "$srcdir/$dir/Doc") || die "Unable to read $dir/Doc";
                     25:   my @docfile = <IN>;
                     26:   close IN;
                     27:   foreach $_ (@docfile) {
                     28:     chomp;
                     29:     /^#/ && next;
                     30:     /^([A-Z]+)\s*(.*)/ || die "Parse error: $_";
                     31:     $cmd = $1;
                     32:     $arg = $2;
                     33:     if ($cmd eq "C") { process("$dir/$arg"); }
                     34:     elsif ($cmd eq "H") {
                     35:       push @stack, "H";
                     36:       print OUT "<chapt>$arg\n";
                     37:     } elsif ($cmd eq "S") {
                     38:       print "    $arg\n";
                     39:       open(DOC, "cd $srcdir/$dir ; $srcdir/doc/kernel-doc -bird $arg |") || die "Unable to start kernel-doc";
                     40:       while (<DOC>) { print OUT; }
                     41:       close DOC;
                     42:     } elsif ($cmd eq "D") {
                     43:       print "    $arg\n";
                     44:       include("$dir/$arg");
                     45:     } else { die "Unknown command: $cmd"; }
                     46:   }
                     47: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>