Pod-Tree

 view release on metacpan or  search on metacpan

mod2html  view on Meta::CPAN

		wanted   => \&Translate,
		no_chdir => 1
	},
	$ModDir
);

Index() if $Options{index};

sub Translate {
	-d and &Translate_Dir;
	-f and &Translate_POD;
}

sub Translate_Dir {
	my $dir   = $File::Find::name;
	my $inode = ( stat $dir )[1];    # always 0 on Win32

	if ( $inode and $inode == $HTML_inode ) {
		$File::Find::prune = 1;
		return;
	}

	$dir =~ s/^$ModDir/$HTMLDir/o;
	-d $dir or mkdir $dir, 0755 or die "Can't mkdir $dir: $!\n";
	print "$File::Find::name\n";
}

sub Translate_POD {
	m( \.(pm|pod)$ )x or return;
	my $source = $File::Find::name;

	Hidden($source) and return;
	print "$source\n";

	my $dest = $source;
	$dest =~ s/^$ModDir/$HTMLDir/;
	$dest =~ s( \.\w+$ )(.html)x;

	my $depth = Depth($source);

	my $pod = $source;
	$pod =~ s(^$ModDir/)();
	$pod =~ s( \.\w+$ )()x;
	$Index{$pod} = 1;

	my $html = Pod::Tree::HTML->new( $source, $dest );
	$html->set_options( %Options, depth => $depth );
	$html->translate;
}

sub Hidden {
	my $source = shift;
	$source =~ m(\.pm$) or return 0;
	$source =~ s(\.pm$)(.pod);
	-e $source;
}

sub Depth {
	my $path = shift;
	$path =~ s(^$ModDir/)();
	my @path = split m(/), $path;
	@path - 1;
}

sub Index {
	my $index = "$HTMLDir/index.html";
	my $fh    = IO::File->new(">$index");
	defined $fh or die "Can't open $index: $!\n";

	my $stream = HTML::Stream->new($fh);

	my $title   = $Options{index};
	my $bgcolor = $Options{bgcolor};
	my $text    = $Options{text};

	$stream->HTML->HEAD;
	$stream->TITLE->text($title)->_TITLE;
	$stream->_HEAD->BODY( BGCOLOR => $bgcolor, TEXT => $text );
	$stream->H1->t($title)->_H1;

	Emit_Entries($stream);

	$stream->_BODY->_HTML;
}

sub Emit_Entries {
	my $stream = shift;

	$stream->UL;

	for my $entry ( sort keys %Index ) {
		$stream->LI->A( HREF => "$entry.html" )->t($entry)->_A->_LI;
	}

	$stream->_UL;
}

__END__

=head1 NAME

mod2html - translate module PODs to HTML

=head1 SYNOPSIS

C<mod2html> 
[C<--base> I<url>]
[C<--css> I<url>]
[C<--index> I<title>]
[C<-->[C<no>]C<toc>] [C<--hr> I<level>] 
[C<--bgcolor> I<#rrggbb>] [C<--text> I<#rrggbb>]
I<modDir> I<HTMLdir>

=head1 DESCRIPTION

C<mod2html> locates all the PODs under I<modDir>
translates them to HTML,
and writes them to a directory tree under F<HTMLdir>.

The directory tree maps the module namespaces.



( run in 0.738 second using v1.01-cache-2.11-cpan-5511b514fd6 )