File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / bird / tools / progdoc
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 19:50:23 2021 UTC (3 years, 3 months ago) by misho
Branches: bird, MAIN
CVS tags: v1_6_8p3, HEAD
bird 1.6.8

    1: #!/usr/bin/perl
    2: 
    3: $srcdir = $ARGV[0];
    4: 
    5: open(OUT, ">prog.sgml") || die "Cannot create output file";
    6: process("", "doc/prog-root");
    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 @_;
   21:   my $doc = "$dir/" . shift @_;
   22:   print "$doc\n";
   23:   open(IN, "$srcdir/$doc") || die "Unable to read $doc";
   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;
   32:     if ($cmd eq "C") { process("$dir/$arg", "Doc"); }
   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>