bfa23b012556d92ef0eadbd9b71031175ad04439
[privoxy.git] / utils / changelog2doc.pl
1 #!/usr/bin/perl
2
3 # $Id: changelog2doc.pl,v 1.3 2010/10/31 13:25:47 fabiankeil Exp $
4 # $Source: /cvsroot/ijbswa/current/utils/changelog2doc.pl,v $
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]{description} = '';
31         }
32         s@^-?\s*@@;
33
34         $entries[$i]{description} .= $_;
35     }
36     print "Parsed " . @entries . " entries.\n";
37 }
38
39 sub create_listitem_markup($) {
40     my $entry = shift;
41     my $description = $entry->{description};
42
43     chomp $description;
44
45     $description =~ s@\n@\n    @g;
46     return "  <listitem>\n" .
47            "   <para>\n" .
48            "    " . $description . "\n" .
49            "   </para>\n" .
50            "  </listitem>\n";
51 }
52
53 sub generate_markup() {
54     my $markup = '';
55
56     $markup .= "<para>\n" .
57                " <itemizedlist>\n";
58
59     foreach my $entry (@entries) {
60         $markup .= create_listitem_markup(\%{$entry});
61     }
62
63     $markup .= " </itemizedlist>\n" .
64                "</para>\n";
65
66     print $markup;
67 }
68
69 sub main () {
70     read_entries();
71     generate_markup();
72 }
73
74 main();