From: Fabian Keil <fk@fabiankeil.de> Date: Sun, 11 May 2008 15:33:35 +0000 (+0000) Subject: - Use descriptive variable names. X-Git-Tag: v_3_0_9~104 X-Git-Url: http://www.privoxy.org/gitweb/@default-cgi@/faq/%22https:/@default-cgi@edit-actions-remove-url?a=commitdiff_plain;h=2becf20eaa0440012213c2d424e245ade1866895;p=privoxy.git - Use descriptive variable names. - Use strict mode. - Add missing colon that got lost in the last commit. - Prepare to support other filter types. --- diff --git a/utils/filter2docs.pl b/utils/filter2docs.pl index cd69d02e..6e519a9b 100755 --- a/utils/filter2docs.pl +++ b/utils/filter2docs.pl @@ -1,22 +1,32 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl -# $Id: filter2docs.pl,v 1.2 2006/07/18 14:49:14 david__schmidt Exp $ +# $Id: filter2docs.pl,v 1.3 2008/05/11 12:31:29 fabiankeil Exp $ # $Source: /cvsroot/ijbswa/current/utils/filter2docs.pl,v $ # Parse the filter names and descriptions from a filter file and # spit out copy&paste-ready markup for the various places in # configuration and documentation where all filters are listed. +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); + while (<INPUT>) { - if (/^FILTER: ([-\w]+) (.*)$/) { - $comment_lines .= "# $1:" . (" " x (20-length($1))) . "$2\n"; - $action_lines .= "+filter{$1} \\\n"; - $sgml_source_1 .= " <para>\n <anchor id=\"filter-$1\">\n <screen>+filter{$1}" . - (" " x (20-length($1))) . "# $2</screen>\n </para>\n"; - $sgml_source_2 .= " -<link linkend=\"FILTER-" . uc($1) . "\">filter{$1}</link> \\\n"; + if (/^(FILTER): ([-\w]+) (.*)$/) { + my $type_uc = $1; + my $name = $2; + my $description = $3; + my $type = lc($type_uc); + + $comment_lines .= "# $name:" . (" " x (20-length($name))) . "$description\n"; + $action_lines .= "+$type" . "{$name} \\\n"; + $sgml_source_1 .= " <para>\n <anchor id=\"$type-$name\">\n <screen>+" . $type . "{$name}" . + (" " x (20-length($name))) . "# $description</screen>\n </para>\n"; + $sgml_source_2 .= " -<link linkend=\"" . $type_uc . "-" . uc($name) . "\">$type" . "{$name}</link> \\\n"; } } @@ -34,7 +44,7 @@ SGML Source for AF chapter in U-M: $sgml_source_1 -SGML Source for AF Tutorial chapter in U-M +SGML Source for AF Tutorial chapter in U-M: $sgml_source_2 DOCMARKUP