App-Pods2Site
view release on metacpan or search on metacpan
lib/App/Pods2Site/SiteBuilder/BasicFramesTreeTOC.pm view on Meta::CPAN
package App::Pods2Site::SiteBuilder::BasicFramesTreeTOC;
use strict;
use warnings;
our $VERSION = '1.003';
my $version = $VERSION;
$VERSION = eval $VERSION;
use base qw(App::Pods2Site::SiteBuilder::AbstractBasicFrames);
use App::Pods2Site::Util qw(slashify readUTF8File writeUTF8File);
sub new
{
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->{maxtocdepth} = -1;
return $self;
}
sub _getCategoryTOC
{
my $self = shift;
my $groupName = shift;
my $podInfo = shift;
my $sitedir = shift;
my $toc = '';
my %tree;
foreach my $podName (sort(keys(%$podInfo)))
{
my $treeloc = \%tree;
for my $level (split(/::/, $podName))
{
$treeloc->{$level} = {} unless exists($treeloc->{$level});
$treeloc = $treeloc->{$level};
}
}
$self->_genRefs($sitedir, \$toc, $podInfo, \%tree, -1);
chomp($toc);
if ($toc)
{
if ($groupName)
{
$toc = qq(<details class="toc-top">\n\t\t\t<summary class="toc-top">$groupName</summary>\n\t\t\t\t$toc\n\t\t</details>\n);
}
else
{
my $newtoc = '';
while ($toc =~ /class="toc-(top|\d+)"/g)
{
my $lvl = ($1 == 0) ? 'top' : $1 - 1;
$newtoc .= substr( $toc, 0, $-[0] ) . qq(class="toc-$lvl");
$toc = substr( $toc, $+[0] );
}
$toc = "$newtoc$toc";
}
}
return $toc;
}
sub _genRefs
{
my $self = shift;
my $sitedir = shift;
my $ref = shift;
my $podInfo = shift;
my $treeloc = shift;
my $depth = shift;
my $n = shift;
my $np = shift;
$self->{maxtocdepth} = $depth if $depth > $self->{maxtocdepth};
( run in 1.691 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )