diff options
author | Martin Mares <mj@ucw.cz> | 2000-05-05 19:14:44 +0200 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2000-05-05 19:14:44 +0200 |
commit | c7d7794bb9a71be58d06c6c9ea67943d3e33a566 (patch) | |
tree | 772c08bf8b84b51c635beffd6e50b9034272472b | |
parent | 249d238c14cafa812db02ea3090b34c58b183cf6 (diff) | |
download | bird-c7d7794bb9a71be58d06c6c9ea67943d3e33a566.tar bird-c7d7794bb9a71be58d06c6c9ea67943d3e33a566.zip |
Added a tool for processing of developer documentation.
Everything is controlled by Doc files in source directories (see the
corresponding programmer's manual entry for the format and look
at Doc and lib/Doc for an example).
Currently it generates HTML indices and calls kernel-doc to generate
per-section HTML files.
-rwxr-xr-x | tools/progdoc | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/tools/progdoc b/tools/progdoc new file mode 100755 index 0000000..ebb97db --- /dev/null +++ b/tools/progdoc @@ -0,0 +1,77 @@ +#!/usr/bin/perl + +$srcdir = $ARGV[0]; + +open(OUT, ">prog/index.html") || die "Cannot create output file"; +html_header(*OUT{IO}, "BIRD: The Developer's Guide"); +print OUT "<H1>BIRD: The Developer's Guide</H1>\n"; +print OUT "<UL>\n"; +process(""); +html_footer(*OUT{IO}); +print OUT "</UL>\n"; +close OUT; +exit 0; + +sub process { + my $dir = shift @_; + print "$dir/Doc\n"; + open(IN, "$srcdir/$dir/Doc") || die "Unable to read $dir/Doc"; + my @docfile = <IN>; + 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 "</UL>\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: $_"; + if ($cmd eq "C") { process("$dir/$arg"); } + elsif ($cmd eq "H") { + push @stack, "H"; + print OUT "<LI>$arg"; + print OUT "<UL>\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 "<LI><A HREF=\"$1.html\">$2</A>\n"; + html_header(*AUX{IO}, "BIRD: $2"); + } 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 (<DOC>) { print AUX; } + close DOC; + } elsif ($cmd eq "X") { + } else { die "Unknown command: $cmd"; } + } +} + +sub html_header { + my $out = shift @_; + my $title = shift @_; + print $out <<EOF +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<HTML><HEAD><TITLE>$title</TITLE> +<LINK REV=MADE HREF="mailto:bird\@atrey.karlin.mff.cuni.cz"> +</HEAD><BODY> +EOF +; +} + +sub html_footer { + my $out = shift @_; + print $out <<EOF +</BODY></HTML> +EOF +; +} |