3 ##########################################################################
5 # $Id: changelog2doc.pl,v 1.7 2010/10/31 13:29:31 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 . " </listitem>\n";
90 $markup .= $lws . "</itemizedlist>\n";
93 $markup .= $lws . " </para>\n" .
94 $lws . "</listitem>\n";
100 sub wrap_in_para_itemlist_markup($) {
102 my $markup = "<para>\n" .
103 " <itemizedlist>\n" .
105 " </itemizedlist>\n" .
110 sub generate_markup() {
113 foreach my $entry (@entries) {
114 $markup .= create_listitem_markup(\%{$entry});
117 print wrap_in_para_itemlist_markup($markup);