Cómo documentar parámetros en Perl POD
Tengo este POD:
=head1 My code
=head2 check
Checks something.
Parameters:
=over 8
=item what to check.
=back
=cut
podcheckerno se queja. perldocmuestra esto:
My code
check
Checks something.
Parameters:
what to check.
Esperaba que la línea "qué comprobar" tuviera más sangría.
¿Cómo necesito cambiar mi POD para mostrar los parámetros con sangría? ¿Hay una mejor manera de hacer esto que con =items?
Respuestas
Ambos perldoce pod2htmlignoran el nivel de sangría . Utilice viñetas como solución. Vea un ejemplo a continuación.
=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
La ejecución perldoc /path/to/script.plda como resultado esto:
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
REFERENCIAS:
La opción de nivel de sangría a "= over" indica qué tanto se debe sangrar, generalmente en ems (donde un em es el ancho de una "M" en la fuente base del documento) o unidades aproximadamente comparables; si no hay una opción de nivel de sangría , el valor predeterminado es cuatro. ( Y algunos formateadores pueden simplemente ignorar cualquier nivel de sangría que proporciones ) .
(De perldoc perlpod, negrita mía)
Por favor, estudie mi código de plantilla, necesitará tenerlo Getopt::Longe Pod::Usageinstalarlo.
Podrás ejecutar este script con opciones --many --helpgenerar documentación breve y 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 ayuda 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.