如何解决如何在Perl POD中记录参数
我有这个POD:
=head1 My code
=head2 check
Checks something.
Parameters:
=over 8
=item what to check.
=back
=cut
podchecker
没有抱怨。 perldoc
显示如下:
My code
check
Checks something.
Parameters:
what to check.
我希望“要检查的内容”行进一步缩进。
如何更改POD以显示缩进的参数?
有没有比=item
更好的方法了?
解决方法
perldoc
和pod2html
都忽略 indentlevel 。使用项目符号作为解决方法。请参见下面的示例。
=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.pl
会导致以下结果:
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
参考:
“ = over”的 indentlevel 选项指示缩进的距离, 通常以ems为单位(其中em是“ M”的宽度 文档的基本字体)或大致可比的单位;如果没有 indentlevel 选项,默认为四个。 (有些格式化程序可能只是 忽略您提供的 indentlevel 。)
(摘自perldoc perlpod
,是黑体字)
请研究我的模板代码,您将需要安装Getopt::Long
和Pod::Usage
。
您将能够使用选项--man
和--help
运行此脚本,以生成简短而完整的文档。
#!/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
手册页 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,...
HISTORY
The section gives historical information related to the code of the
program
COPYRIGHT
Copyright information related to the code
帮助页面 script.pl-帮助
program.pl [options] file(s)
Options:
-i,--man full documentation
Options:
-i,--help
Print a brief help message and exits.
--man
Prints the manual page and exits.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。