Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Find and convert all pod to html

by Anonymous Monk
on Apr 09, 2019 at 23:39 UTC ( [id://1232376]=note: print w/replies, xml ) Need Help??


in reply to Find and convert all pod to html

Thank you for this script. I am using strawberry perl and cannot install ActivePerl::DocTools over cpan. So I deciced to change the script a little and coded my own TOC-file creation:
use strict; use Pod::Html; use Pod::Find qw(pod_find); use File::Path; my $infile_path_root = "C:/MySw/Strawberry5.28x64/perl"; my $outfile_path_root = "C:/MySw/Strawberry5.28x64/html"; my $alternativeIndexFile = "$outfile_path_root/my_alternative_index.ht +ml"; my $logfile = "C:/MySw/Strawberry5.28x64/allpod.txt"; my %pods = pod_find({ -verbose => 0, -inc => 1 }); my (@sorted); foreach my $podfile (keys %pods) { $podfile =~ s#\\#/#g; my ($path,$name) = ($podfile =~ m!^$infile_path_root(/.+)?/([^\/]+ +)\.(pod|pm|pl)$!io); my (@depth) = ($path =~ /(\/)/go); my $depth = scalar @depth; my $sorted = sprintf("%010d%-s",$depth,$podfile); push(@sorted,$sorted); } open INDEX, ">$alternativeIndexFile" || die "Cannot open $alternativeI +ndexFile\n"; print INDEX "<html><head><title>Strawberry Perl Documentation - Versio +n 5.28</title></head>\n"; print INDEX "<body>\n<blockquote>\n<h2>Strawberry Perl Documentation - + Version 5.28</h2>\n"; print INDEX "<h3>Table of Content</h3>\n"; open LOG, ">$logfile" || die "Cannot open $logfile\n"; pmpod2html(); close(LOG); print INDEX "</blockquote>\n</body></html>\n"; close(INDEX); sub pmpod2html { my ($prepath,$predepth); foreach my $podfile (sort @sorted) { $podfile =~ s/^\d{10}//o; my ($path,$name) = ($podfile =~ m!^$infile_path_root(/.+)?/([^ +\/]+)\.(pod|pm|pl)$!io); $path =~ s/^\///o; my (@depth) = ($path =~ /(\/)/go); my $depth = scalar @depth; print INDEX '</blockquote>' x$predepth . "\n" . '<blockquote>' + x$depth . "\n\n" . "<b>$path</b><br>\n" if($prepath ne $path); if (! -e "$outfile_path_root/$path/$name\.html") { mkpath("$outfile_path_root/$path"); pod2html( "--infile=$podfile", "--outfile=$outfile_path_root/$path/$name.html", "--podroot=$infile_path_root", "--podpath=lib:site:vendor", ); my ($htmlfile); open(IN,"<$outfile_path_root/$path/$name.html") || die "Ca +nnot open $outfile_path_root/$path/$name.html\n"; while(<IN>) { $htmlfile .= $_; } my ($title) = ($htmlfile =~ /<title>\s*(.+?)\s*<\/title>/i +os); close(IN); print LOG "$podfile\n"; if($title) { print INDEX "$title: <a href=\"$path/$name.ht +ml\">$name.html</a><br>\n"; } else { print INDEX "<a href=\"$path/$name.html\">$name.htm +l</a><br>\n"; } } $prepath = $path; $predepth = $depth; } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1232376]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-03-28 22:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found