From: Fabian Keil Date: Mon, 12 May 2008 09:31:36 +0000 (+0000) Subject: - Generate markup for all filter types currently supported by Privoxy. X-Git-Tag: v_3_0_9~103 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=054ad713eac089669ff2e936d82132fdf4e5b582 - Generate markup for all filter types currently supported by Privoxy. - Put code into subroutines. --- diff --git a/utils/filter2docs.pl b/utils/filter2docs.pl index 6e519a9b..1a4c0a06 100755 --- a/utils/filter2docs.pl +++ b/utils/filter2docs.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# $Id: filter2docs.pl,v 1.3 2008/05/11 12:31:29 fabiankeil Exp $ +# $Id: filter2docs.pl,v 1.4 2008/05/11 15:33:35 fabiankeil Exp $ # $Source: /cvsroot/ijbswa/current/utils/filter2docs.pl,v $ # Parse the filter names and descriptions from a filter file and @@ -10,41 +10,72 @@ use strict; use warnings; -die "Usage: $0 filter-file\n" unless (@ARGV == 1) ; -open(INPUT, "< $ARGV[0]") or die "Coudln't open input file $ARGV[0] because $!\n"; +my (%comment_lines, %action_lines, %sgml_source_1, %sgml_source_2); -my ($comment_lines, $action_lines, $sgml_source_1, $sgml_source_2); +sub main() { -while () { - if (/^(FILTER): ([-\w]+) (.*)$/) { - my $type_uc = $1; - my $name = $2; - my $description = $3; - my $type = lc($type_uc); + die "Usage: $0 filter-file\n" unless (@ARGV == 1) ; + open(INPUT, "< $ARGV[0]") or die "Coudln't open input file $ARGV[0] because $!\n"; - $comment_lines .= "# $name:" . (" " x (20-length($name))) . "$description\n"; - $action_lines .= "+$type" . "{$name} \\\n"; - $sgml_source_1 .= " \n \n +" . $type . "{$name}" . - (" " x (20-length($name))) . "# $description\n \n"; - $sgml_source_2 .= " -$type" . "{$name} \\\n"; - } + parse_file(); + print_markup(); } -print <) { + if (/^((?:(?:SERVER|CLIENT)-HEADER-)?(?:FILTER|TAGGER)): ([-\w]+) (.*)$/) { + my $type_uc = $1; + my $name = $2; + my $description = $3; + my $type = lc($type_uc); + + my $white_space = ' ' x (($type eq 'filter' ? 20 : 27) - length($name)); + + $comment_lines{$type} .= "# $name:" . $white_space . "$description\n"; + $action_lines{$type} .= "+$type" . "{$name} \\\n"; + $sgml_source_1{$type} .= " \n \n" . + " +$type" . "{$name}" . $white_space . + "# $description\n \n"; + $sgml_source_2{$type} .= ' -$type" . "{$name} \\\n"; + } + } +} -Comment lines for default.action: +sub print_markup() { -$comment_lines + my @filter_types = ( + 'filter', + 'server-header-filter', + 'client-header-filter', + 'server-header-tagger', + 'client-header-tagger' + ); -Block of filter actions for standard.action: + foreach my $type (@filter_types) { -$action_lines + next unless defined $action_lines{$type}; -SGML Source for AF chapter in U-M: + print "=" x 90; + + print <<" DOCMARKUP"; + +Producing $type markup: + +Comment lines for default.action: + +$comment_lines{$type} +Block of $type actions for standard.action: -$sgml_source_1 +$action_lines{$type} +SGML Source for AF chapter in U-M: +$sgml_source_1{$type} SGML Source for AF Tutorial chapter in U-M: -$sgml_source_2 -DOCMARKUP +$sgml_source_2{$type} + DOCMARKUP + } +} + +main();