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

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

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