~ubuntu-branches/ubuntu/saucy/freecell-solver/saucy

« back to all changes in this revision

Viewing changes to scripts/gen-man-page.pl

  • Committer: Package Import Robot
  • Author(s): Gergely Risko
  • Date: 2012-06-22 10:08:05 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120622100805-evoda1ccdr8vt5xr
Tags: 3.12.0-1
New upstream version. (closes: #675262)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
use strict;
 
4
use warnings;
 
5
 
 
6
use Getopt::Long;
 
7
 
 
8
=head1 NAME
 
9
 
 
10
gen-man-page.pl
 
11
 
 
12
=head1 DESCRIPTION
 
13
 
 
14
This script generates man pages ready AsciiDoc document from the more
 
15
generic documents such as C<README.txt> or C<USAGE.txt>.
 
16
 
 
17
=cut
 
18
 
 
19
sub _slurp
 
20
{
 
21
    my $filename = shift;
 
22
 
 
23
    open my $in, "<", $filename
 
24
        or die "Cannot open '$filename' for slurping - $!";
 
25
 
 
26
    local $/;
 
27
    my $contents = <$in>;
 
28
 
 
29
    close($in);
 
30
 
 
31
    return $contents;
 
32
}
 
33
 
 
34
my ($readme_path, $usage_path, $out_path);
 
35
 
 
36
GetOptions(
 
37
    'readme=s' => \$readme_path,
 
38
    'usage=s' => \$usage_path,
 
39
    'output=s' => \$out_path,
 
40
)
 
41
    or die "Cannot process arguments.";
 
42
 
 
43
my $readme = _slurp($readme_path);
 
44
my $usage = _slurp($usage_path);
 
45
 
 
46
$usage =~ s{\A.*?(^The programs *$)}{$1}ms;
 
47
 
 
48
my $manify_text = <<'EOF';
 
49
:doctype: manpage
 
50
 
 
51
NAME
 
52
----
 
53
fc-solve - automated solver for Freecell and related Solitiare variants
 
54
EOF
 
55
 
 
56
my $man_title = 'fc-solve(6)';
 
57
 
 
58
$readme =~ s/\AFreecell Solver Readme File\n(=+)\n/
 
59
    $man_title . "\n" . '=' x length($man_title) . "\n"/ge;
 
60
$readme =~ s/(:Revision[^\n]*\n)/$1$manify_text/ms;
 
61
 
 
62
open my $out, '>', $out_path;
 
63
print {$out} $readme, "\n\n", $usage;
 
64
close($out);
 
65
 
 
66
=head1 COPYRIGHT AND LICENSE
 
67
 
 
68
Copyright (c) 2000 Shlomi Fish
 
69
 
 
70
Permission is hereby granted, free of charge, to any person
 
71
obtaining a copy of this software and associated documentation
 
72
files (the "Software"), to deal in the Software without
 
73
restriction, including without limitation the rights to use,
 
74
copy, modify, merge, publish, distribute, sublicense, and/or sell
 
75
copies of the Software, and to permit persons to whom the
 
76
Software is furnished to do so, subject to the following
 
77
conditions:
 
78
 
 
79
The above copyright notice and this permission notice shall be
 
80
included in all copies or substantial portions of the Software.
 
81
 
 
82
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
83
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 
84
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
85
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 
86
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 
87
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
88
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
89
OTHER DEALINGS IN THE SOFTWARE.
 
90
 
 
91
 
 
92
 
 
93
=cut
 
94