#--- manual.t ----------------------------------------------------------------- # function: Test HTML::ToC generating a manual. use strict; use Test; BEGIN { plan tests => 1; } use Data::Dumper; use File::Find; use HTML::Toc; use HTML::TocGenerator; use HTML::TocInsertor; use HTML::TocUpdator; # Create objects my $toc = HTML::Toc->new(); my $tocGenerator = HTML::TocGenerator->new(); my @fileList; #--- TestSiteMap() ------------------------------------------------------------ # function: Test specifying numbered list. sub TestSiteMap { # Set ToC options $toc->setOptions({ 'doLinkToFile' => 1, 'templateAnchorName' => '""', 'templateAnchorHref' => '""', 'doLinkTocToToken' => 1, 'tokenToToc' => [{ 'groupId' => 'dir', 'level' => 1, 'tokenBegin' => '', 'tokenEnd' => '', 'fileSpec' => '\./[^/]+$' }, { 'groupId' => 'dir', 'level' => 2, 'tokenBegin' => '', 'tokenEnd' => '', 'fileSpec' => '\./[^/]+?/[^/]+$' }, { 'groupId' => 'dir', 'level' => 3, 'tokenBegin' => '', 'tokenEnd' => '', 'fileSpec' => '\./[^/]+?/[^/]+?/[^/]+$' }] }); # Change current directory chdir("t/SiteMap"); # Find files, filling 'fileList' find({wanted => \&WantedSiteMap, no_chdir => 1}, '.'); # Generate ToC of case-insensitively sorted file list $tocGenerator->extendFromFile( $toc, [sort {uc($a) cmp uc($b)} @fileList] ); # Restore current directory chdir("../.."); # Test ToC ok($toc->format(), < EOT } # TestSiteMap() #--- WantedSiteMap() ---------------------------------------------------------- # function: 'Wanted' function, used by File::Find of 'TestSiteMap()'. sub WantedSiteMap { # Add file to 'fileList' if extension matches '.htm' push (@fileList, $File::Find::name) if (m/\.htm$/); } # WantedSiteMap() # Test site map TestSiteMap();