X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=utils%2Fchangelog2doc.pl;h=a81f80c6f48e8ea0595037fa8a6cdef85a8273e0;hp=adf2f9227581b48e1a4793fa0f77184119b0f9fd;hb=873efe14859c0fb3f53a905eb346c36cf5fe7eda;hpb=078c345f510037f52ccc0f831822b968a42e3f0a diff --git a/utils/changelog2doc.pl b/utils/changelog2doc.pl index adf2f922..a81f80c6 100755 --- a/utils/changelog2doc.pl +++ b/utils/changelog2doc.pl @@ -1,11 +1,25 @@ #!/usr/bin/perl -# $Id:$ -# $Source:$ - +########################################################################## +# # Filter to parse the ChangeLog and translate the changes for # the most recent version into something that looks like markup # for the documentation but still needs fine-tuning. +# +# Copyright (c) 2008, 2010 Fabian Keil +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +########################################################################## use strict; use warnings; @@ -25,37 +39,80 @@ sub read_entries() { next unless $section_reached; next if /^\s*$/; - if (/^-/) { + if (/^(\s*)- /) { + my $indentation = length($1); + if ($i > 1 and $entries[$i]{indentation} > $indentation) { + $entries[$i]{last_list_item} = 1; + } $i++; - $entries[$i] = ''; + $entries[$i]{description} = ''; + $entries[$i]{indentation} = $indentation; + } + if (/:\s*$/) { + $entries[$i]{list_header} = 1; } - s@^-?\s*@@; - $entries[$i] .= $_; + s@^\s*-?\s*@@; + + $entries[$i]{description} .= $_; } - print "Parsed $i entries.\n"; + if ($entries[$i]{indentation} != 0) { + $entries[$i]{last_list_item} = 1; + } + print "Parsed " . @entries . " entries.\n"; } -sub generate_markup() { +sub create_listitem_markup($) { + my $entry = shift; + my $description = $entry->{description}; my $markup = ''; + my $default_lws = ' '; + my $lws = $default_lws x ($entry->{indentation} ? 2 : 1); + + chomp $description; + + $description =~ s@\n@\n ${lws}@g; + + $markup .= $lws . "\n" . + $lws . " \n"; + + $markup .= $lws . " " . $description . "\n"; + + if (defined $entry->{list_header}) { + $markup .= $lws . " \n"; - $markup .= "\n" . - " \n"; + } else { + if (defined $entry->{last_list_item}) { + $markup .= $lws . " \n"; + $markup .= $lws . " \n"; + $markup .= $lws . "\n"; + $lws = $default_lws; + } + $markup .= $lws . " \n" . + $lws . "\n"; + } + + return $markup; +} + +sub wrap_in_para_itemlist_markup($) { + my $content = shift; + my $markup = "\n" . + " \n" . + " $content" . + " \n" . + "\n"; + return $markup; +} + +sub generate_markup() { + my $markup = ''; foreach my $entry (@entries) { - chomp $entry; - $entry =~ s@\n@\n @g; - $markup .= " \n" . - " \n" . - " " . $entry . "\n" . - " \n" . - " \n" - ; + $markup .= create_listitem_markup(\%{$entry}); } - $markup .= " \n" . - "\n"; - print $markup; + print wrap_in_para_itemlist_markup($markup); } sub main () {