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