App-PODUtils
view release on metacpan or search on metacpan
script/elide-pod view on Meta::CPAN
#!perl
our $DATE = '2021-07-20'; # DATE
our $VERSION = '0.050'; # VERSION
use 5.010001;
use strict;
use warnings;
use App::PODUtils;
use Perinci::CmdLine::Any;
our %SPEC;
$SPEC{elide_pod} = {
v => 1.1,
summary => 'Elide POD',
description => <<'_',
This utility elides (shortens POD to a target number of lines) by removing POD
lines with `..`. It will first try to elide text lines first, then POD commands.
_
args => {
pod_file => {
schema => 'str*',
default => '-',
pos => 0,
},
lines => {
summary => 'Target number of lines (default is one page)',
schema => 'posint*',
},
retain_level => {
summary => 'How much to retain POD commands',
schema => ['int*', in=>[1..9]],
default => 9,
},
},
};
sub elide_pod {
require Pod::Elide;
my %args = @_;
my $pod_file = $args{pod_file};
return [404, "No such file"] unless (-f $pod_file) || $pod_file eq '-';
my $pod = do {
open my $fh, $pod_file
or return [500, "Can't open file '$pod_file': $!"];
local $/;
scalar <$fh>;
};
return [
200, "OK",
Pod::Elide::elide(
$pod, $args{lines} // $ENV{LINES} // 24,
{
retain_level => $args{retain_level},
}),
{'cmdline.skip_format' => 1},
];
}
Perinci::CmdLine::Any->new(
url => '/main/elide_pod',
)->run;
# ABSTRACT: Elide POD
# PODNAME: elide-pod
__END__
=pod
=encoding UTF-8
=head1 NAME
elide-pod - Elide POD
=head1 VERSION
This document describes version 0.050 of elide-pod (from Perl distribution App-PODUtils), released on 2021-07-20.
=head1 SYNOPSIS
Usage:
% B<elide-pod> [B<--config-path>=I<path>|B<-c>|B<--no-config>|B<-C>] [B<--config-profile>=I<profile>|B<-P>] [B<--format>=I<name>|B<--json>] [B<--lines>=I<posint>] [B<--(no)naked-res>] [B<--no-env>] [B<--page-result>[=I<program>]|B<--view-result>[=I<p...
=head1 DESCRIPTION
=head1 OPTIONS
C<*> marks required options.
=head2 Main options
=over
=item B<--lines>=I<s>
Target number of lines (default is one page).
=item B<--pod-file>=I<s>
( run in 1.319 second using v1.01-cache-2.11-cpan-39bf76dae61 )