~ubuntu-branches/ubuntu/intrepid/sgt-puzzles/intrepid

« back to all changes in this revision

Viewing changes to debian/patches/301_make-more-docs.diff

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings
  • Date: 2008-04-13 17:39:38 UTC
  • mfrom: (1.1.6 upstream) (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080413173938-hvr14r6s8p5ctwnt
Tags: 7983-1
* New upstream release
* Moved common code into a private shared library, halving package
  size and installed size
* Implemented highlighting of more kinds of error in Loopy
* Changed encoding of copyright file to UTF-8
* Updated standards-version to 3.7.3 (no other changes required)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--- sgt-puzzles.orig/Makefile.doc
2
 
+++ sgt-puzzles/Makefile.doc
3
 
@@ -1,6 +1,18 @@
4
 
-all: puzzles.hlp puzzles.txt HACKING
5
 
+MAN_PAGES := blackboxgame.6 bridges.6 cube.6 dominosa.6 fifteen.6 flipgame.6 \
6
 
+    guess.6 inertia.6 lightup.6 loopy.6 map.6 mines.6 netgame.6 netslide.6 \
7
 
+    pattern.6 pegs.6 rect.6 samegame.6 sixteen.6 slant.6 solo.6 tents.6 \
8
 
+    twiddle.6 untangle.6
9
 
 
10
 
-puzzles.hlp puzzles.txt: puzzles.but
11
 
+HTML_PAGES := common.html docindex.html index.html intro.html licence.html \
12
 
+    blackbox.html bridges.html cube.html dominosa.html fifteen.html flip.html \
13
 
+    guess.html inertia.html lightup.html loopy.html map.html mines.html \
14
 
+    net.html netslide.html pattern.html pegs.html rectangles.html \
15
 
+    samegame.html sixteen.html slant.html solo.html tents.html twiddle.html \
16
 
+    untangle.html
17
 
+
18
 
+all: puzzles.hlp puzzles.cnt puzzles.txt HACKING $(MAN_PAGES) $(HTML_PAGES)
19
 
+
20
 
+puzzles.hlp puzzles.cnt puzzles.txt: puzzles.but
21
 
        halibut --winhelp=puzzles.hlp --text=puzzles.txt puzzles.but
22
 
 
23
 
 HACKING: devel.but
24
 
@@ -10,5 +22,11 @@
25
 
 puzzles.hhp: puzzles.but chm.but
26
 
        halibut --html puzzles.but chm.but
27
 
 
28
 
+$(MAN_PAGES): puzzles.but
29
 
+       perl mkmanpages.pl
30
 
+
31
 
+$(HTML_PAGES): puzzles.but
32
 
+       halibut --html puzzles.but
33
 
+
34
 
 clean:
35
 
-       rm -f puzzles.hlp puzzles.txt HACKING *.html *.hh[pck]
36
 
+       rm -f puzzles.hlp puzzles.cnt puzzles.txt HACKING *.6 *.html *.hh[pck]
37
 
--- sgt-puzzles.orig/mkmanpages.pl
38
 
+++ sgt-puzzles/mkmanpages.pl
39
 
@@ -0,0 +1,173 @@
40
 
+#!/usr/bin/perl -w
41
 
+
42
 
+# Generate manual pages for sgt-puzzles by running extracts of puzzles.but
43
 
+# through halibut.
44
 
+
45
 
+use strict;
46
 
+use File::Temp;
47
 
+use IO::File;
48
 
+
49
 
+# Header information
50
 
+my $package = "sgt\\-puzzles";
51
 
+my $date;
52
 
+my $section = "Games";
53
 
+my $section_no = "6";
54
 
+
55
 
+# Name of command corresponding to each game-specific chapter name
56
 
+my %commands = (blackbox       => 'blackboxgame',
57
 
+               bridges         => 'bridges',
58
 
+               cube            => 'cube',
59
 
+               dominosa        => 'dominosa',
60
 
+               fifteen         => 'fifteen',
61
 
+               filling         => 'filling',
62
 
+               flip            => 'flipgame',
63
 
+               galaxies        => 'galaxies',
64
 
+               guess           => 'guess',
65
 
+               inertia         => 'inertia',
66
 
+               lightup         => 'lightup',
67
 
+               loopy           => 'loopy',
68
 
+               map             => 'map',
69
 
+               mines           => 'mines',
70
 
+               net             => 'netgame',
71
 
+               netslide        => 'netslide',
72
 
+               pattern         => 'pattern',
73
 
+               pegs            => 'pegs',
74
 
+               rectangles      => 'rect',
75
 
+               samegame        => 'samegame',
76
 
+               sixteen         => 'sixteen',
77
 
+               slant           => 'slant',
78
 
+               solo            => 'solo',
79
 
+               tents           => 'tents',
80
 
+               twiddle         => 'twiddle',
81
 
+               unequal         => 'unequal',
82
 
+               untangle        => 'untangle');
83
 
+my %short_descs = (blackboxgame        => 'guessing game',
84
 
+                  bridges      => 'topological deduction game',
85
 
+                  cube         => 'tile manipulation puzzle game',
86
 
+                  dominosa     => 'domino puzzle game',
87
 
+                  fifteen      => 'tile manipulation puzzle game',
88
 
+                  filling      => 'puzzle game',
89
 
+                  flipgame     => 'tile manipulation puzzle game',
90
 
+                  galaxies     => 'puzzle game',
91
 
+                  guess        => 'guessing game based on Mastermind',
92
 
+                  inertia      => 'puzzle game',
93
 
+                  lightup      => 'puzzle game',
94
 
+                   loopy        => 'topological deduction game',
95
 
+                  map          => 'map colouring game',
96
 
+                  mines        => 'game based on Minesweeper',
97
 
+                  netgame      => 'tile manipulation puzzle game based on FreeNet',
98
 
+                  netslide     => 'tile manipulation puzzle game',
99
 
+                  pattern      => 'nonogram puzzle game',
100
 
+                  pegs         => 'peg solitaire puzzle game',
101
 
+                  rect         => 'puzzle game based on Divide by Squares',
102
 
+                  samegame     => 'puzzle game',
103
 
+                  sixteen      => 'tile manipulation puzzle game',
104
 
+                  slant        => 'topological deduction game',
105
 
+                  solo         => 'puzzle game based on Sudoku',
106
 
+                  tents        => 'puzzle game',
107
 
+                  twiddle      => 'tile manipulation puzzle game',
108
 
+                  unequal      => 'puzzle game based on Futoshiki',
109
 
+                  untangle     => 'puzzle game based on Planarity');
110
 
+
111
 
+my @MONTHS = qw(January February March April May June
112
 
+               July August September October November December);
113
 
+
114
 
+# Chapter name, initialised to dummy value to capture header
115
 
+my $name = '__HEADER__';
116
 
+
117
 
+# Contents of each chapter/appendix
118
 
+my %contents;
119
 
+
120
 
+# Gather chapters from the original documentation
121
 
+my $source = new IO::File;
122
 
+$source->open("<puzzles.but") or die "puzzles.but: $!";
123
 
+while (<$source>) {
124
 
+    # Look for chapter/appendix heading
125
 
+    if (/^\\[AC]{([^}]+)}\s*/) {
126
 
+       $name = $1;
127
 
+    }
128
 
+    # Look for version ID with date
129
 
+    if (/^\\versionid \$Id: [^ ]+ \d+ (\d{4})-(\d{2})-\d{2} /) {
130
 
+       $date = "${MONTHS[$2-1]} $1";
131
 
+    }
132
 
+    $contents{$name} .= $_;
133
 
+}
134
 
+close $source;
135
 
+
136
 
+# Remove all normal text from the header
137
 
+$contents{__HEADER__} =~ s/^(?!\\(?:cfg|define|title){).*$//gm;
138
 
+
139
 
+# Remove introduction from "common features" chapter
140
 
+$contents{common} =~ s/^.*?(?=\\H{)//s;
141
 
+
142
 
+for my $chapter (keys %commands) {
143
 
+
144
 
+    my $command = $commands{$chapter};
145
 
+    print "Generating $command.6\n";
146
 
+
147
 
+    my $contents =
148
 
+      "\\cfg{man-mindepth}{1}\n" # don't show original chapter headings
149
 
+      . "\\cfg{man-identity}{".uc($command)."}{$section_no}{$date}{$command ($package)}{$section}\n\n"
150
 
+      . $contents{__HEADER__}
151
 
+      . "\\C{man-$command} $command\n\n" # dummy chapter
152
 
+      . "\\H{man-$command-name} NAME\n\n"
153
 
+      . "\\c{$command} \\- $short_descs{$command}\n\n"
154
 
+      . "\\H{man-$command-synopsis} SYNOPSIS\n\n"
155
 
+      . "\\cw{$command} [\\cw{--generate }\\e{n}]\n"
156
 
+      . "[\\cw{--print }\\e{w}\\cw{x}\\e{h} [\\cw{--with-solutions}]\n"
157
 
+      . "[\\cw{--scale }\\e{n}] [\\cw{--colour}]]\n"
158
 
+      . "[\\e{game-parameters}|\\e{game-ID}|\\e{random-seed}]\n\n"
159
 
+      . "\\cw{$command --version}\n\n"
160
 
+      . "\\H{man-$command-desc} DESCRIPTION\n\n"
161
 
+      . $contents{$chapter}
162
 
+      . $contents{common}
163
 
+      . "\\H{man-$command-see-also} SEE ALSO\n\n"
164
 
+      . "Full documentation in /usr/share/doc/$package/puzzles.txt.gz.\n";
165
 
+
166
 
+    # Kluge cross-references
167
 
+    sub replace_ref {
168
 
+       my ($above, $target, $below) = @_;
169
 
+       # If the target is an earlier or later section in the current page, say
170
 
+       # it's above or below.
171
 
+       if ($above =~ m/\\(?:[CHA]|S\d*){$target}/) {
172
 
+           'above';
173
 
+       } elsif ($below =~ m/\\(?:[CHA]|S\d*){$target}/) {
174
 
+           'below';
175
 
+       }
176
 
+       # Else if the target is a bibliographic entry, include the entry directly.
177
 
+       elsif ($below =~ m/\\B{$target}\s*(.*?)\s*(?:\\(?:[BCHA]|S\d*|$))/s) {
178
 
+           "($1)";
179
 
+       }
180
 
+       # Else if it appears to refer to another game, convert to a customary
181
 
+       # cross-manual-page reference.
182
 
+       elsif ($target =~ /(\w+)/ && exists $commands{$1}) {
183
 
+           "\\e{$commands{$1}}($section_no)";
184
 
+       }
185
 
+       # Otherwise (and this shouldn't happen), show the reference target.
186
 
+       else {
187
 
+           print STDERR "Failed to resolve reference to $target\n";
188
 
+           $target;
189
 
+       }
190
 
+    }
191
 
+    $contents =~ s/(?:\bin\s+)?\\[kK]{([^}]+)}/replace_ref($`, $1, $')/eg;
192
 
+
193
 
+    # Run through halibut, working around bug #320333 (fixed for etch,
194
 
+    # but this source is meant to build under sarge too).
195
 
+    # halibut does not default to using stdin or stdout, and
196
 
+    # /dev/std{in,out} apparently don't exist on some systems, so we
197
 
+    # can't reliably do this with a pipeline.
198
 
+    my ($temp_but, $temp_but_name) = mkstemp "/tmp/sgt-puzzles-but-XXXXXX"
199
 
+      or die "$!";
200
 
+    print $temp_but $contents or die "$!";
201
 
+    close $temp_but;
202
 
+    my ($temp_man, $temp_man_name) = mkstemp "/tmp/sgt-puzzles-man-XXXXXX"
203
 
+      or die "$!";
204
 
+    close $temp_man;
205
 
+    system "halibut --man=$temp_man_name $temp_but_name";
206
 
+    system "grep -v '^\\.UC' <$temp_man_name >$command.6";
207
 
+    unlink $temp_but_name;
208
 
+    unlink $temp_man_name;
209
 
+    -s "$command.6" or die "halibut produced an empty $command.6";
210
 
+}
211
 
+
212
 
+exit;