- Use descriptive variable names.
[privoxy.git] / utils / filter2docs.pl
1 #!/usr/bin/perl
2
3 # $Id: filter2docs.pl,v 1.3 2008/05/11 12:31:29 fabiankeil Exp $
4 # $Source: /cvsroot/ijbswa/current/utils/filter2docs.pl,v $
5
6 # Parse the filter names and descriptions from a filter file and
7 # spit out copy&paste-ready markup for the various places in
8 # configuration and documentation where all filters are listed.
9
10 use strict;
11 use warnings;
12
13 die "Usage: $0 filter-file\n" unless (@ARGV == 1) ;
14 open(INPUT, "< $ARGV[0]") or die "Coudln't open input file $ARGV[0] because $!\n";
15
16 my ($comment_lines, $action_lines, $sgml_source_1, $sgml_source_2);
17
18 while (<INPUT>) {
19   if (/^(FILTER): ([-\w]+) (.*)$/) {
20     my $type_uc = $1;
21     my $name = $2;
22     my $description = $3;
23     my $type = lc($type_uc);
24
25     $comment_lines .= "#     $name:" . (" " x (20-length($name))) . "$description\n";
26     $action_lines  .= "+$type" . "{$name} \\\n";
27     $sgml_source_1 .= "   <para>\n    <anchor id=\"$type-$name\">\n    <screen>+" . $type . "{$name}" .
28                       (" " x (20-length($name))) . "# $description</screen>\n   </para>\n";
29     $sgml_source_2 .= " -<link linkend=\"" . $type_uc . "-" . uc($name) . "\">$type" . "{$name}</link> \\\n";
30   }
31 }
32
33 print <<DOCMARKUP;
34
35 Comment lines for default.action:
36
37 $comment_lines
38
39 Block of filter actions for standard.action:
40
41 $action_lines
42
43 SGML Source for AF chapter in U-M:
44
45 $sgml_source_1
46
47 SGML Source for AF Tutorial chapter in U-M:
48
49 $sgml_source_2
50 DOCMARKUP