1 #!/usr/bin/perl 2 3 # Transform RELEASE_NOTES, split into "leader", and "major changes", 4 # split into major categories, and prepend dates to paragraphs. 5 # 6 # Input format: the leader text is copied verbatim; each section 7 # starts with "Incompatible changes with snapshot YYYYMMDD" or "Major 8 # changes with snapshot YYYYMMDD" underlined with "=======..."; each 9 # paragraph starts with [class, class] where a class specifies one or 10 # more categories that the change should be listed under. Adding class 11 # info is the only manual processing needed to go from a RELEASE_NOTES 12 # file to the transformed representation. 13 # 14 # Output format: each category is printed with a little header and each 15 # paragraph is tagged with [Incompat yyyymmdd] or with [Feature yyyymmdd]. 16 17 %leader = (); %body = (); 18 $append_to = \%leader; 19 20 while (<>) { 21 22 if (/^(Incompatible changes|Incompatibility) with/) { 23 die "No date found: $_" unless /(\d\d\d\d\d\d\d\d)/; 24 $append_to = \%body; 25 $prefix = "[Incompat $1] "; 26 while (<>) { 27 last if /^====/; 28 } 29 next; 30 } 31 32 if (/^Major changes with/) { 33 die "No date found: $_" unless /(\d\d\d\d\d\d\d\d)/; 34 $append_to = \%body; 35 $prefix = "[Feature $1] "; 36 while (<>) { 37 last if /^====/; 38 } 39 next; 40 } 41 42 if (/^\s*\n/) { 43 if ($paragraph) { 44 for $class (@classes) { 45 ${$append_to}{$class} .= $paragraph . $_; 46 } 47 $paragraph = ""; 48 } 49 } else { 50 if ($paragraph eq "") { 51 if ($append_to eq \%leader) { 52 @classes = ("default"); 53 $paragraph = $_; 54 } elsif (/^\[([^]]+)\]\s*(.*)/s) { 55 $paragraph = $prefix . $2; 56 ($junk = $1) =~ s/\s*,\s*/,/g; 57 $junk =~ s/^\s+//; 58 $junk =~ s/\s+$//; 59 #print "junk >$junk<\n"; 60 @classes = split(/,+/, $junk); 61 #print "[", join(', ', @classes), "] ", $paragraph; 62 } else { 63 $paragraph = $_; 64 } 65 } else { 66 $paragraph .= $_; 67 } 68 } 69 } 70 71 if ($paragraph) { 72 for $class (@classes) { 73 ${$append_to}{$class} .= $prefix . $paragraph . $_; 74 } 75 } 76 77 print $leader{"default"}; 78 79 for $class (sort keys %body) { 80 print "Major changes - $class\n"; 81 ($junk = "Major changes - $class") =~ s/./-/g; 82 print $junk, "\n\n"; 83 print $body{$class}; 84 } 85