如何生成目录中 Perl 模块或脚本的 HTML 摘要?

发布于 2024-08-25 16:36:39 字数 320 浏览 12 评论 0原文

是否有可用的工具可以在目录树中生成 perl 模块或脚本的 HTML 摘要列表?

鉴于

 =head1 NAME

 wibble.pl - does wibble actions

我希望看到类似的东西

<a href="docsforwibble">wibble.pl</a> - does wibble actions
<a href="docsforwobble">wobble.pl</a> - does wobble actions

Is there a tool available that can produce an HTML summary list of perl modules or scripts in a directory tree?

Given

 =head1 NAME

 wibble.pl - does wibble actions

I would like to see something like

<a href="docsforwibble">wibble.pl</a> - does wibble actions
<a href="docsforwobble">wobble.pl</a> - does wobble actions

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

离线来电— 2024-09-01 16:36:40

pod2html --recurse --podpath

请参阅 perldoc pod2html

pod2html --recurse --podpath <dirname>

See perldoc pod2html

剩余の解释 2024-09-01 16:36:40

使用 Pod::FindPod::Find 可以轻松地找到一个="http://search.cpan.org/dist/Pod-Parser" rel="nofollow noreferrer">Pod::Parser 分发。

下面的脚本为它可以在我的 site/lib/CGI 下找到的任何内容创建一个基本索引文件。它的目的是作为演示。使用 pod2html 可能会更好,但这个脚本可能仍然有用。

#!/usr/bin/perl

use strict; use warnings;
use autodie;

use File::Spec::Functions qw( canonpath );
use HTML::Template;
use Pod::Find qw(pod_find simplify_name);
use Pod::Select;

my $mod_top = canonpath 'c:/opt/perl/site/lib/CGI';
my $html_top = 'c:/opt/perl/html/site/lib/CGI';

my %pods = pod_find($mod_top);
my @pods;

for my $pod ( sort keys %pods ) {
    (my $link = $pod) =~ s/^\Q$mod_top//;
    $link =~ s/\.\w+\z//;
    $link = "file:///${html_top}${link}.html";

    my $name;
    {
        local *STDOUT;
        open STDOUT, '>', \$name;
        podselect({-sections => [ 'NAME' ] }, $pod);
    }
    $name = '' unless defined $name;
    $name =~ s/^=head1\s+NAME\s+//;
    $name =~ s/\s+\z//;

    push @pods, {
        POD => $pods{$pod},
        NAME => $name,
        LINK => $link,
    };
}

my $tmpl = HTML::Template->new(scalarref => \ <<EO_TMPL
<!DOCTYPE HTML>
<html>
<head><title>Index of Perl Modules</title></head>
<body>
<h1><TMPL_VAR CATEGORY></h1>
<dl>
<TMPL_LOOP PODS>
<dt><a href="<TMPL_VAR LINK>"><TMPL_VAR POD></a></dt>
<dd><TMPL_VAR NAME></dd>
</TMPL_LOOP>
</ul>
</body>
</html>
EO_TMPL
);

$tmpl->param(
    CATEGORY => 'CGI',
    PODS => \@pods,
);
$tmpl->output(print_to => \*STDOUT);

It is easy to whip one out using Pod::Find from the Pod::Parser distribution.

The script below creates a rudimentary index file for anything it can find under my site/lib/CGI. It is meant as a demonstration. You are probably better off with pod2html, but this script might still be useful.

#!/usr/bin/perl

use strict; use warnings;
use autodie;

use File::Spec::Functions qw( canonpath );
use HTML::Template;
use Pod::Find qw(pod_find simplify_name);
use Pod::Select;

my $mod_top = canonpath 'c:/opt/perl/site/lib/CGI';
my $html_top = 'c:/opt/perl/html/site/lib/CGI';

my %pods = pod_find($mod_top);
my @pods;

for my $pod ( sort keys %pods ) {
    (my $link = $pod) =~ s/^\Q$mod_top//;
    $link =~ s/\.\w+\z//;
    $link = "file:///${html_top}${link}.html";

    my $name;
    {
        local *STDOUT;
        open STDOUT, '>', \$name;
        podselect({-sections => [ 'NAME' ] }, $pod);
    }
    $name = '' unless defined $name;
    $name =~ s/^=head1\s+NAME\s+//;
    $name =~ s/\s+\z//;

    push @pods, {
        POD => $pods{$pod},
        NAME => $name,
        LINK => $link,
    };
}

my $tmpl = HTML::Template->new(scalarref => \ <<EO_TMPL
<!DOCTYPE HTML>
<html>
<head><title>Index of Perl Modules</title></head>
<body>
<h1><TMPL_VAR CATEGORY></h1>
<dl>
<TMPL_LOOP PODS>
<dt><a href="<TMPL_VAR LINK>"><TMPL_VAR POD></a></dt>
<dd><TMPL_VAR NAME></dd>
</TMPL_LOOP>
</ul>
</body>
</html>
EO_TMPL
);

$tmpl->param(
    CATEGORY => 'CGI',
    PODS => \@pods,
);
$tmpl->output(print_to => \*STDOUT);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文