Add a filter to make updating the "What's New in this Release"
[privoxy.git] / utils / changelog2doc.pl
1 #!/usr/bin/perl
2
3 # $Id:$
4 # $Source:$
5
6 # Filter to parse the ChangeLog and translate the changes for
7 # the most recent version into something that looks like markup
8 # for the documentation but still needs fine-tuning.
9
10 use strict;
11 use warnings;
12
13 my @entries;
14
15 sub read_entries() {
16     my $section_reached = 0;
17     my $i = -1;
18
19     while (<>) {
20         if (/^\*{3} /) {
21             last if $section_reached;
22             $section_reached = 1;
23             next;
24         }
25         next unless $section_reached;
26         next if /^\s*$/;
27
28         if (/^-/) {
29             $i++; 
30             $entries[$i] = '';
31         }
32         s@^-?\s*@@;
33
34         $entries[$i] .= $_;
35     }
36     print "Parsed $i entries.\n";
37 }
38
39 sub generate_markup() {
40     my $markup = '';
41
42     $markup .= "<para>\n" .
43                " <itemizedlist>\n";
44
45     foreach my $entry (@entries) {
46         chomp $entry;
47         $entry =~ s@\n@\n    @g;
48         $markup .= "  <listitem>\n" .
49                    "   <para>\n" .
50                    "    " . $entry . "\n" .
51                    "   </para>\n" .
52                    "  </listitem>\n"
53                    ;
54     }
55     $markup .= " </itemizedlist>\n" .
56                "</para>\n";
57
58     print $markup;
59 }
60
61 sub main () {
62     read_entries();
63     generate_markup();
64 }
65
66 main();