File: gen-man-page.pl

package info (click to toggle)
freecell-solver 5.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,256 kB
  • sloc: ansic: 28,700; perl: 10,050; xml: 5,600; python: 1,339; sh: 533; cpp: 275; makefile: 20; javascript: 8
file content (59 lines) | stat: -rw-r--r-- 1,431 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use strict;
use warnings;

use Getopt::Long qw/ GetOptions /;
use Path::Tiny qw/ path /;

=head1 NAME

gen-man-page.pl

=head1 DESCRIPTION

This script generates a man page-ready AsciiDoc document from the more
generic documents such as C<README.txt> or C<USAGE.txt>.

=cut

my ( $readme_path, $usage_path, $out_path );

GetOptions(
    'readme=s' => \$readme_path,
    'usage=s'  => \$usage_path,
    'output=s' => \$out_path,
) or die "Cannot process arguments.";

my $readme = path($readme_path)->slurp_utf8;
my $usage  = path($usage_path)->slurp_utf8;

$usage =~ s{\A.*?(^The programs *$)}{$1}ms;

my $MANIFY_TEXT = <<'EOF';
:doctype: manpage

NAME
----
fc-solve - automated solver for Freecell and related Solitiare variants
EOF

my $TITLE = 'fc-solve(6)';

$readme =~ s/\AFreecell Solver Readme File\n(=+)\n/
    $TITLE . "\n" . '=' x length($TITLE) . "\n"/ge;
$readme =~ s/(:Revision[^\n]*\n)/$1$MANIFY_TEXT/ms;

path($out_path)->spew_utf8( $readme, "\n\n", $usage );

__END__

=head1 COPYRIGHT AND LICENSE

This file is part of Freecell Solver. It is subject to the license terms in
the COPYING.txt file found in the top-level directory of this distribution
and at http://fc-solve.shlomifish.org/docs/distro/COPYING.html . No part of
Freecell Solver, including this file, may be copied, modified, propagated,
or distributed except according to the terms contained in the COPYING file.

Copyright (c) 2000 Shlomi Fish

=cut