Como documentar parâmetros em Perl POD
Eu tenho este POD:
=head1 My code
=head2 check
Checks something.
Parameters:
=over 8
=item what to check.
=back
=cut
podcheckernão reclama. perldocmostra isso:
My code
check
Checks something.
Parameters:
what to check.
Eu esperava que a linha "o que verificar" fosse indentada ainda mais.
Como eu preciso mudar meu POD para mostrar os parâmetros recuados? Existe uma maneira melhor de fazer isso do que com =items?
Respostas
Ambos perldoce pod2htmlignorar o nível de recuo . Use marcadores como uma solução alternativa. Veja um exemplo abaixo.
=head1 My code
=head2 check with no bullets or numbers
Checks something.
Parameters:
=over
=item what to check A
=item what to check B
=back
=head2 check with bullets
Checks something.
=over
=item * what to check A
=item * what to check B
=back
=head2 check with numbers
Checks something.
=over
=item 1. what to check A
=item 2. what to check B
=back
=cut
perldoc /path/to/script.plResultados em execução neste:
My code
check with no bullets or numbers
Checks something.
Parameters:
what to check A
what to check B
check with bullets
Checks something.
o what to check A
o what to check B
check with numbers
Checks something.
1. what to check A
2. what to check B
REFERÊNCIAS:
A opção indentlevel para "= over" indica a distância a ser recuada, geralmente em ems (onde um em é a largura de um "M" na fonte base do documento) ou unidades aproximadamente comparáveis; se não houver opção de nível de recuo , o padrão é quatro. ( E alguns formatadores podem simplesmente ignorar qualquer nível de recuo que você fornecer. )
(De perldoc perlpod, negrito meu)
Por favor, estude meu código de modelo, você precisará ter Getopt::Longe Pod::Usageinstalado.
Você poderá executar este script com opções --mane --helpgerar uma documentação breve e completa.
#!/usr/bin/perl
#
# Description:
# Describe purpose of the program
#
# Parameters:
# Describe parameters purpose
#
# Date: Tue Nov 29 1:18:00 UTC 2019
#
# Author: Polar Bear
# https://stackoverflow.com/users/12313309/polar-bear
#
use strict;
use warnings;
use Getopt::Long qw(GetOptions);
use Pod::Usage;
use Data::Dumper;
my %opt;
my @args = (
'input|i=s',
'output|o=s',
'debug|d',
'help|?',
'man|m'
);
GetOptions( \%opt, @args ) or pod2usage(2);
print Dumper(\%opt) if $opt{debug}; pod2usage(1) if $opt{help};
pod2usage(-exitval => 0, -verbose => 2) if $opt{man}; pod2usage("$0: No files given.") if ((@ARGV == 0) && (-t STDIN));
__END__
=head1 NAME
program - brief on program's purpose
=head1 SYNOPSIS
program.pl [options] file(s)
Options:
-i,--input input filename
-o,--output output filename
-d,--debug output debug information
-?,--help brief help message
-m,--man full documentation
=head1 OPTIONS
=over 4
=item B<-i,--input>
Input filename
=item B<-o,--output>
Output filename
=item B<-d,--debug>
Print debug information.
=item B<-?,--help>
Print a brief help message and exits.
=item B<--man>
Prints the manual page and exits.
=back
=head1 DESCRIPTION
B<This program> accepts B<input> and processes to B<output> with purpose of achiving some goal.
=head1 EXIT STATUS
The section describes B<EXIT STATUS> codes of the program
=head1 ENVIRONMENT
The section describes B<ENVIRONMENT VARIABLES> utilized in the program
=head1 FILES
The section describes B<FILES> which used for program's configuration
=head1 EXAMPLES
The section demonstrates some B<EXAMPLES> of the code
=head1 REPORTING BUGS
The section provides information how to report bugs
=head1 AUTHOR
The section describing author and his contanct information
=head1 ACKNOWLEDGMENT
The section to give credits people in some way related to the code
=head1 SEE ALSO
The section describing related information - reference to other programs, blogs, website, ...
=head1 HISTORY
The section gives historical information related to the code of the program
=head1 COPYRIGHT
Copyright information related to the code
=cut
Página de manual script.pl --man
NAME
program - brief on program's purpose
SYNOPSIS
program.pl [options] file(s)
Options:
-i,--input input filename
-o,--output output filename
-d,--debug output debug information
-?,--help brief help message
-m,--man full documentation
OPTIONS
-i,--input
Input filename
-o,--output
Output filename
-d,--debug
Print debug information.
-?,--help
Print a brief help message and exits.
--man
Prints the manual page and exits.
DESCRIPTION
This program accepts input and processes to output with purpose of
achiving some goal.
EXIT STATUS
The section describes EXIT STATUS codes of the program
ENVIRONMENT
The section describes ENVIRONMENT VARIABLES utilized in the program
FILES
The section describes FILES which used for program's configuration
EXAMPLES
The section demonstrates some EXAMPLES of the code
REPORTING BUGS
The section provides information how to report bugs
AUTHOR
The section describing author and his contanct information
ACKNOWLEDGMENT
The section to give credits people in some way related to the code
SEE ALSO
The section describing related information - reference to other
programs, blogs, website, ...
HISTORY
The section gives historical information related to the code of the
program
COPYRIGHT
Copyright information related to the code
Página de ajuda script.pl --help
program.pl [options] file(s)
Options:
-i,--input input filename
-o,--output output filename
-d,--debug output debug information
-?,--help brief help message
-m,--man full documentation
Options:
-i,--input
Input filename
-o,--output
Output filename
-d,--debug
Print debug information.
-?,--help
Print a brief help message and exits.
--man
Prints the manual page and exits.