1
--- sgt-puzzles.orig/Makefile.doc
2
+++ sgt-puzzles/Makefile.doc
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 \
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 \
18
+all: puzzles.hlp puzzles.cnt puzzles.txt HACKING $(MAN_PAGES) $(HTML_PAGES)
20
+puzzles.hlp puzzles.cnt puzzles.txt: puzzles.but
21
halibut --winhelp=puzzles.hlp --text=puzzles.txt puzzles.but
25
puzzles.hhp: puzzles.but chm.but
26
halibut --html puzzles.but chm.but
28
+$(MAN_PAGES): puzzles.but
31
+$(HTML_PAGES): puzzles.but
32
+ halibut --html puzzles.but
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
42
+# Generate manual pages for sgt-puzzles by running extracts of puzzles.but
50
+my $package = "sgt\\-puzzles";
52
+my $section = "Games";
53
+my $section_no = "6";
55
+# Name of command corresponding to each game-specific chapter name
56
+my %commands = (blackbox => 'blackboxgame',
57
+ bridges => 'bridges',
59
+ dominosa => 'dominosa',
60
+ fifteen => 'fifteen',
61
+ filling => 'filling',
63
+ galaxies => 'galaxies',
65
+ inertia => 'inertia',
66
+ lightup => 'lightup',
71
+ netslide => 'netslide',
72
+ pattern => 'pattern',
74
+ rectangles => 'rect',
75
+ samegame => 'samegame',
76
+ sixteen => 'sixteen',
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');
111
+my @MONTHS = qw(January February March April May June
112
+ July August September October November December);
114
+# Chapter name, initialised to dummy value to capture header
115
+my $name = '__HEADER__';
117
+# Contents of each chapter/appendix
120
+# Gather chapters from the original documentation
121
+my $source = new IO::File;
122
+$source->open("<puzzles.but") or die "puzzles.but: $!";
124
+ # Look for chapter/appendix heading
125
+ if (/^\\[AC]{([^}]+)}\s*/) {
128
+ # Look for version ID with date
129
+ if (/^\\versionid \$Id: [^ ]+ \d+ (\d{4})-(\d{2})-\d{2} /) {
130
+ $date = "${MONTHS[$2-1]} $1";
132
+ $contents{$name} .= $_;
136
+# Remove all normal text from the header
137
+$contents{__HEADER__} =~ s/^(?!\\(?:cfg|define|title){).*$//gm;
139
+# Remove introduction from "common features" chapter
140
+$contents{common} =~ s/^.*?(?=\\H{)//s;
142
+for my $chapter (keys %commands) {
144
+ my $command = $commands{$chapter};
145
+ print "Generating $command.6\n";
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";
166
+ # Kluge cross-references
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}/) {
173
+ } elsif ($below =~ m/\\(?:[CHA]|S\d*){$target}/) {
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) {
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)";
185
+ # Otherwise (and this shouldn't happen), show the reference target.
187
+ print STDERR "Failed to resolve reference to $target\n";
191
+ $contents =~ s/(?:\bin\s+)?\\[kK]{([^}]+)}/replace_ref($`, $1, $')/eg;
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"
200
+ print $temp_but $contents or die "$!";
202
+ my ($temp_man, $temp_man_name) = mkstemp "/tmp/sgt-puzzles-man-XXXXXX"
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";