From 6be13de762cebc9fc5f977e0e3423a9e2ae23a95 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 31 May 2000 11:29:56 +0000 Subject: New progdoc script generating SGML output. --- tools/progdoc | 72 +++++++++++++++++------------------------------------------ 1 file changed, 21 insertions(+), 51 deletions(-) (limited to 'tools') diff --git a/tools/progdoc b/tools/progdoc index ebb97db..2294712 100755 --- a/tools/progdoc +++ b/tools/progdoc @@ -2,76 +2,46 @@ $srcdir = $ARGV[0]; -open(OUT, ">prog/index.html") || die "Cannot create output file"; -html_header(*OUT{IO}, "BIRD: The Developer's Guide"); -print OUT "

BIRD: The Developer's Guide

\n"; -print OUT "\n"; +include("prog-foot.sgml"); close OUT; exit 0; +sub include { + my $f = shift @_; + open(IN, "$srcdir/doc/$f") || die "Unable to find $f"; + while () { + print OUT; + } + close IN; +} + sub process { my $dir = shift @_; print "$dir/Doc\n"; open(IN, "$srcdir/$dir/Doc") || die "Unable to read $dir/Doc"; my @docfile = ; - my @stack = (); close IN; - push @docfile, "X\n"; foreach $_ (@docfile) { chomp; /^#/ && next; - /^(\.*)([A-Z]+)\s*(.*)/ || die "Parse error: $_"; - $indent = length $1; - $cmd = $2; - $arg = $3; - while (@stack > $indent) { - $x = pop @stack; - if ($x eq "H") { print OUT "\n"; } - elsif ($x eq "F") { html_footer(*AUX{IO}); close AUX; } - else { print STDERR "Unknown stack element $x\n"; } - } - (@stack == $indent) or die "Invalid nesting: $_"; + /^([A-Z]+)\s*(.*)/ || die "Parse error: $_"; + $cmd = $1; + $arg = $2; if ($cmd eq "C") { process("$dir/$arg"); } elsif ($cmd eq "H") { push @stack, "H"; - print OUT "
  • $arg"; - print OUT "
      \n"; - } elsif ($cmd eq "F") { - $arg =~ /^(\S+)\s+(.*)$/ || die "Invalid command: $_"; - push @stack, "F"; - print " $1\n"; - open(AUX, ">prog/$1.html") || die "Unable to create output file"; - print OUT "
    • $2\n"; - html_header(*AUX{IO}, "BIRD: $2"); + print OUT "$arg\n"; } elsif ($cmd eq "S") { print " $arg\n"; - open(DOC, "cd $srcdir/$dir ; $srcdir/doc/kernel-doc -html $arg |") || die "Unable to start kernel-doc"; - while () { print AUX; } + open(DOC, "cd $srcdir/$dir ; $srcdir/doc/kernel-doc -bird $arg |") || die "Unable to start kernel-doc"; + while () { print OUT; } close DOC; - } elsif ($cmd eq "X") { + } elsif ($cmd eq "D") { + print " $arg\n"; + include($arg); } else { die "Unknown command: $cmd"; } } } - -sub html_header { - my $out = shift @_; - my $title = shift @_; - print $out < -$title - - -EOF -; -} - -sub html_footer { - my $out = shift @_; - print $out < -EOF -; -} -- cgit v1.2.3