Blame view

src/doc/make_tools.sh 1.82 KB
8dcb6dfcb   Yannick Estève   first commit
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
48
49
50
51
52
53
54
55
  #!/bin/bash
  
  # Copyright 2012  Daniel Povey.  Apache 2.0.
  # Creates the file tools.dox from tools.dox.input
  # and the source code.
  # to be run from ..
  
  echo "Making tools.dox from source files"
  [ ! -f doc/make_tools.sh ] && echo "You are running this script from the wrong directory" && exit 1;
  
  
  for d in *bin; do
    if [ -d $d ] && [ -f $d/Makefile ]; then
      cat $d/Makefile | perl -ane ' while(<>){ s/\\
  //g; print; }' | grep -E '^BINFILES' | awk '{for(n=3;n<=NF;n++){print $n;}}' > tmpf;
      for binfile in `cat tmpf`; do 
          perl -e 'use File::Basename;  $/ = "zyx"; $f=$ARGV[0]; while(<>) {
        m/char\s*\*\s*usage\s*=((\s*\".+\"\s*
  )*(\s*\".+\";\s*
  ))/ || die "bad $f
  "; #=\s*(\"[.
  ]+\");\s*
  / || die "could not find usage message for file $f
  "; 
        $msg = $1;  
        $msg =~ s/^\s*\"//g || die "(file is $f)"; # Remove initial quotes.
        $msg =~ s/\";\s*$//g || die "(file is $f)"; # Remove final quotes.
        $msg =~ s/\"\s*
  \s*\"//g; # remove intermediate quotes.
        $msg =~ s/\\\"/\"/g; # Un-escape escaped quotes.
        $msg =~ s/\
  /
  /g; # Turn escaped newlines into newlines.
        $msg =~ s/\\\t/\t/g; # Turn escaped tabs into tabs.
        $msg =~ s/
  \s*$//g; # Remove the final newline.
        $basef = basename($f);
        $basef =~ s/.cc$//;
        $output = "<tr> <td> \\ref $f \"$basef\" </td><td> <pre> $msg </pre> </td> </tr>";
        # $output =~ s|
  |<br/>|g; # make it so newlines are marked up.
        print "$output
  ";
       } ' $d/$binfile.cc
      done
    fi
  done > doc/table;
  
  ! perl -e '$/ = "xyicfab"; open(F, "<$ARGV[0]") || die "opening $ARGV[0]";
     open(G, "<$ARGV[1]") || die "opening $ARGV[1]";
     $table = <G>;
     $file = <F>;
     $file =~ s:PUT_DATA_HERE:$table: || die "No match!";
     print $file; ' doc/tools.dox.input doc/table >doc/tools.dox \
    && echo "Making tools.dox did not work." && exit 1;