curl_json plugin: Split cj_append_key() out of cj_config_add_key().
[collectd.git] / contrib / wiki2changelog.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 =head1 NAME
7
8 wiki2changelog.pl
9
10 =head1 DESCRIPTION
11
12 This script takes the change log from one of the "Version x.y" pages in
13 collectd's wiki and converts it to the format used by the "ChangeLog" file.
14 This is usually done as part of the release process.
15
16 =cut
17
18 our $TextWidth = 80;
19
20 sub format_entry
21 {
22         my $in = shift;
23         my $out = '';
24
25         my $line = "\t*";
26         my $line_len = 9;
27
28         for (split (' ', $in)) {
29                 my $word = $_;
30                 my $word_len = 1 + length $word;
31
32                 if (($line_len + $word_len) > $TextWidth) {
33                         $out .= "$line\n";
34                         $line = "\t ";
35                         $line_len = 9;
36                 }
37
38                 $line .= " $word";
39                 $line_len += $word_len;
40         }
41
42         if ($line_len != 9) {
43                 $out .= "$line\n";
44         }
45
46         return $out;
47 }
48
49 while (<>)
50 {
51         chomp;
52         my $line = $_;
53
54         if ($line =~ m#^\* (.*)#) {
55                 $line = $1;
56         } else {
57                 next;
58         }
59
60         $line =~ s#&lt;#<#g;
61         $line =~ s#&gt;#>#g;
62         $line =~ s#&nbsp;# #g;
63         $line =~ s#&quot;#"#g;
64
65         $line =~ s#\{\{Plugin\|([^}]+)\}\}#$1 plugin#g;
66         $line =~ s@\{\{Issue\|([^}]+)\}\}@#$1@g;
67         $line =~ s#\[\[[^|\]]+\|([^\]]+)\]\]#$1#g;
68         $line =~ s#\[\[([^|\]]+)\]\]#$1#g;
69
70         $line =~ s#'''(.*?)'''#*$1*#g;
71         $line =~ s#''(.*?)''#$1#g;
72         $line =~ s#<code>(.*?)</code>#"$1"#gi;
73
74         print format_entry($line);
75 }