summaryrefslogtreecommitdiff
path: root/tools/progdoc
blob: 2294712ec445c89aa97411628e0a028f7833e1bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl

$srcdir = $ARGV[0];

open(OUT, ">prog.sgml") || die "Cannot create output file";
include("prog-head.sgml");
process("");
include("prog-foot.sgml");
close OUT;
exit 0;

sub include {
  my $f = shift @_;
  open(IN, "$srcdir/doc/$f") || die "Unable to find $f";
  while (<IN>) {
    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 = <IN>;
  close IN;
  foreach $_ (@docfile) {
    chomp;
    /^#/ && next;
    /^([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 "<sect>$arg\n";
    } elsif ($cmd eq "S") {
      print "    $arg\n";
      open(DOC, "cd $srcdir/$dir ; $srcdir/doc/kernel-doc -bird $arg |") || die "Unable to start kernel-doc";
      while (<DOC>) { print OUT; }
      close DOC;
    } elsif ($cmd eq "D") {
      print "    $arg\n";
      include($arg);
    } else { die "Unknown command: $cmd"; }
  }
}