/usr/bin/pod2readme is in libpod-readme-perl 1.1.2-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | #!/usr/bin/env perl
use v5.10.1;
use strict;
use warnings;
use File::Copy qw/ copy /;
use Getopt::Long::Descriptive;
use IO::Handle;
use Pod::Readme;
=head1 NAME
pod2readme - Intelligently generate a README file from POD
=head1 USAGE
pod2readme [-cfho] [long options...] input-file [output-file] [target]
Intelligently generate a README file from POD
-t --target target type (default: 'readme')
-f --format output format (default: 'text')
-b --backup backup output file
-o --output output filename (default based on target)
-c --stdout output to stdout (console)
-F --force only update if files are changed
-h --help print usage and exit
=head1 SYNOPSIS
pod2readme -f markdown lib/MyApp.pm
=head1 DESCRIPTION
This utility will use L<Pod::Readme> to extract a F<README> file from
a POD document.
It works by extracting and filtering the POD, and then calling the
appropriate filter program to convert the POD to another format.
=head1 OPTIONS
=head2 C<--backup>
By default, C<pod2readme> will back up the output file. To disable
this, use the C<--no-backup> option.
=head2 C<--output>
Specifies the name of the output file. If omitted, it will use the
second command line argument, or default to the C<--target> plus the
corresponding extension of the C<--format>.
For all intents, the default is F<README>.
If a format other than "text" is chosen, then the appropriate
extension will be added, e.g. for "markdown", the default output file
is F<README.md>.
=head2 C<--target>
The target of the filter, which defaults to "readme".
=head2 C<--format>
The output format, which defaults to "text".
Other supposed formats are "html", "latex", "man", "markdown", "pod",
"rtf", and "xhtml".
=head2 C<--stdout>
If enabled, it will output to the console instead of C<--output>.
=head2 C<--force>
By default, the F<README> will be generated if the source files have
been changed. Using C<--force> will force the file to be updated.
Note: POD format files will always be updated.
=head2 C<--help>
Prints the usage and exits.
=head1 SEE ALSO
L<pod2text>, L<pod2markdown>.
=cut
my %FORMATS = (
'html' => { class => 'Pod::Simple::HTML', },
'latex' => { class => 'Pod::Simple::LaTeX' },
'man' => { class => 'Pod::Man' },
'markdown' => { class => 'Pod::Markdown' },
'pod' => { class => undef },
'rtf' => { class => 'Pod::Simple::RTF' },
'text' => { class => 'Pod::Simple::Text' },
'xhtml' => { class => 'Pod::Simple::XHTML' },
);
sub validate_format {
my $value = shift;
if ( exists $FORMATS{$value} ) {
return $value;
}
else {
die "Invalid format: '${value}'\n";
}
}
my ( $opt, $usage ) = describe_options(
'%c %o input-file [output-file] [target]',
[],
['Intelligently generate a README file from POD'],
[],
[ 'target|t=s' => "target type (default: 'readme')" ],
[
'format|f=s' => "output format (default: 'text')",
{
default => 'text',
callbacks => { format => \&validate_format },
}
],
[ 'backup|b!' => "backup output file", { default => 1 } ],
[ 'output|o' => "output filename (default based on target)" ],
[ 'stdout|c' => "output to stdout (console)" ],
[ 'force|F!' => "only update if files are changed" ],
[ 'help|h' => "print usage and exit" ],
);
die $usage if $opt->help;
my %args = ( force => $opt->force );
if ( my $input = shift @ARGV ) {
$args{input_file} = $input;
}
my $format = $FORMATS{ $opt->format };
unless ($format) {
say sprintf( "Unknown format: '\%s'", $opt->format );
die $usage;
}
my $output = $opt->output || shift @ARGV;
my $target = $opt->target || shift @ARGV || 'readme';
$args{target} = $target;
if ( my $class = $format->{class} ) {
$args{translation_class} = $class;
}
if ( $opt->stdout ) {
my $fh = IO::Handle->new;
if ( $fh->fdopen( fileno(STDOUT), 'w' ) ) {
$args{translate_to_fh} = $fh;
}
else {
die "Cannot get a filehandle for STDOUT";
}
}
else {
$args{translate_to_file} = $output if $output;
}
my $pr = Pod::Readme->new(%args);
$output ||= $pr->translate_to_file;
if ( $opt->backup && $output && -e $output ) {
copy( $output, $output . '.bak' );
}
$pr->run();
|