3 ##########################################################################
5 # $Id: changelog2doc.pl,v 1.2 2008/09/26 16:49:09 fabiankeil Exp $
7 # Filter to parse the ChangeLog and translate the changes for
8 # the most recent version into something that looks like markup
9 # for the documentation but still needs fine-tuning.
11 # Copyright (c) 2008, 2010 Fabian Keil <fk@fabiankeil.de>
13 # Permission to use, copy, modify, and distribute this software for any
14 # purpose with or without fee is hereby granted, provided that the above
15 # copyright notice and this permission notice appear in all copies.
17 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
18 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
19 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
20 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
21 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
22 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
23 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 ##########################################################################
32 my $section_reached = 0;
37 last if $section_reached;
41 next unless $section_reached;
45 my $indentation = length($1);
46 if ($i > 1 and $entries[$i]{indentation} > $indentation) {
47 $entries[$i]{last_list_item} = 1;
50 $entries[$i]{description} = '';
51 $entries[$i]{indentation} = $indentation;
54 $entries[$i]{list_header} = 1;
59 $entries[$i]{description} .= $_;
61 if ($entries[$i]{indentation} != 0) {
62 $entries[$i]{last_list_item} = 1;
64 print "Parsed " . @entries . " entries.\n";
67 sub create_listitem_markup($) {
69 my $description = $entry->{description};
71 my $default_lws = ' ';
72 my $lws = $default_lws x ($entry->{indentation} ? 2 : 1);
76 $description =~ s@\n@\n ${lws}@g;
78 $markup .= $lws . "<listitem>\n" .
81 $markup .= $lws . " " . $description . "\n";
83 if (defined $entry->{list_header}) {
84 $markup .= $lws . " <itemizedlist>\n";
87 if (defined $entry->{last_list_item}) {
88 $markup .= $lws . " </para>\n";
89 $markup .= $lws . "</itemizedlist>\n";
92 $markup .= $lws . " </para>\n" .
93 $lws . "</listitem>\n";
99 sub wrap_in_para_itemlist_markup($) {
101 my $markup = "<para>\n" .
102 " <itemizedlist>\n" .
104 " </itemizedlist>\n" .
109 sub generate_markup() {
112 foreach my $entry (@entries) {
113 $markup .= create_listitem_markup(\%{$entry});
116 print wrap_in_para_itemlist_markup($markup);