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