PennMUSH Community

root/1.8.3/trunk/utils/mkvershlp.pl

Revision 1167, 2.6 kB (checked in by shawnw, 8 months ago)

Merge devel into trunk for p6 release

  • Property svn:executable set to *
Line 
1 #!/usr/bin/env perl
2 #
3 # Generate game/txt/hlp/ files from the CHANGES file(s).
4 # Should be run by Makefile from top-level directory
5 #
6 # Requires the extra Sort::Versions module. Install through CPAN.
7 #
8 # Usage: mkvershlp game/txt/hlp CHANGES.176 CHANGES.OLD ...
9 #
10 # Each file CHANGES.<blah> generates file pennv<blah>.hlp in the
11 # specified directory.
12 #
13 use strict;
14 use Sort::Versions;
15 use Text::Wrap;
16
17 BEGIN {
18     print "Rebuilding HELP CHANGES entries...\n";
19 }
20
21 END {
22     print "Done.\n";
23 }
24
25 my $targetdir = shift;
26 my @sources = @ARGV;
27 my $verspat = qr'^Version (\S+) patchlevel (\S+)';
28 my %patchlevels;
29
30 @sources = sort byrevision @sources;
31
32 my $really_started = 0;
33 foreach my $file (@sources) {
34   next if $file =~ /~$/o;
35   warn "Can't open $file!\n", next unless open IN, "<", $file;
36   my $target = $file;
37   $target =~ s/.*\.(.*)/pennv$1.hlp/;
38   open(OUT,">","$targetdir/$target") or die "Unable to open $targetdir/$target\n";
39   my $started = 0;
40   while (<IN>) {
41     if (/$verspat/o) {
42       print OUT "& $1p$2\n";
43       push @{$patchlevels{$1}}, $2;
44       unless ($started) {
45         # This is the first one
46         unless ($really_started) {
47           print OUT <<'EOP';
48 & changes
49 This is a list of changes in this patchlevel which are probably of
50 interest to players. More information about new commands and functions
51 can probably be gotten via 'help <name of whatever>'. 'help credits'
52 lists the [initials] of developers and porters that are used in the list
53 of changes.
54
55 Information about changes in prior releases can be found under
56 help topics named for each release (e.g. 'help 1.7.2p30').
57 A list of the patchlevels associated with each release can
58 be read in 'help patchlevels'.
59
60 EOP
61           $really_started = 1;
62         }
63         $started = 1;
64       }
65       print OUT;
66     } elsif ($started) {
67       print OUT;
68     }
69   }
70   close IN;
71 }
72
73 # Now spew the patchlevels list. Special case for 1.50
74 $patchlevels{'1.5.0'} = $patchlevels{'1.50'};
75 delete($patchlevels{'1.50'});
76 my @versions = reverse sort versions keys %patchlevels;
77 print OUT <<EOP;
78 & patchlevels
79 For information on a specific patchlevel of one of the versions listed,
80 type 'help <version>p<patchlevel>'. For example, 'help 1.7.2p3'
81
82 EOP
83 foreach (@versions) {
84   my @pls = sort {$a <=> $b} @{$patchlevels{$_}};
85   my $line;
86   if ($_ eq "1.5.0") {
87     $line = "1.50: ". join(", ",@pls). "\n";
88   } else {
89     $line = "$_: ". join(", ",@pls). "\n";
90   }
91   print OUT wrap("","       ",$line);
92 }
93
94 close OUT;
95
96
97 # A sort subroutine to order CHANGES.<blah> in reverse chronological
98 # order
99 sub byrevision {
100   return $b cmp $a if ($a =~ /\d/ and $b =~ /\d/);
101   return $a cmp $b;
102 }
103
Note: See TracBrowser for help on using the browser.