Adding a documentation index.

This commit is contained in:
sergiotarxz 2022-03-17 18:07:01 +01:00
parent 18fd0de544
commit 823c0633fb
2 changed files with 83 additions and 1 deletions

View File

@ -5,7 +5,10 @@ use v5.30.0;
use strict;
use warnings;
use Data::Dumper;
use Path::Tiny qw/path/;
use Mojo::Template;
my $current_dir = path(__FILE__)->parent->parent->child('lib');
@ -15,8 +18,50 @@ $current_dir->visit(
if ( -f $path ) {
return if $path !~ /\.pm$/;
system mkdir => '-pv', 'doc/' . $path->parent;
system pod2html => $path, '-o', 'doc/' . $path . '.html', '--htmldir', $current_dir->child('./doc')->realpath, '--podpath', 'lib', '--recurse';
system pod2html => $path,
'-o', 'doc/' . $path . '.html', '--htmldir',
$current_dir->child('./doc')->realpath, '--podpath', 'lib',
'--recurse';
}
},
{ recurse => 1 }
);
my $documentation_path = path(__FILE__)->parent->parent->child('doc');
my %modules;
$documentation_path->visit(
sub {
my ( $path, $state ) = @_;
if ( !-f $path ) {
return;
}
if ( $path !~ /\.pm\.html$/ ) {
return;
}
$modules{ $path =~ s{^.*/lib/}{}r =~ s/\.pm\.html$//r =~ s{/}{::}gr } =
''.$path=~s/doc\///r;
},
{ recurse => 1 },
);
my $mojo_template = Mojo::Template->new;
my $html = $mojo_template->render(<<'EOF', \%modules);
% my ($modules) = @_;
<html>
<head>
</head>
<body>
<h1>Welcome to the Peace documentation</h1>
<ul>
% for my $module (sort { $a cmp $b } keys %$modules) {
<li>
<a href="<%=$modules->{$module}%>"><%=$module%></a>
</li>
% }
</ul>
</body>
</html>
EOF
$documentation_path->child('index.html')->spew_utf8($html);

37
doc/index.html Normal file
View File

@ -0,0 +1,37 @@
<html>
<head>
</head>
<body>
<h1>Welcome to the Peace documentation</h1>
<ul>
<li>
<a href="lib/Peace.pm.html">Peace</a>
</li>
<li>
<a href="lib/Peace/Controller/User.pm.html">Peace::Controller::User</a>
</li>
<li>
<a href="lib/Peace/DAO/Application.pm.html">Peace::DAO::Application</a>
</li>
<li>
<a href="lib/Peace/DAO/Customer.pm.html">Peace::DAO::Customer</a>
</li>
<li>
<a href="lib/Peace/DAO/Developer.pm.html">Peace::DAO::Developer</a>
</li>
<li>
<a href="lib/Peace/DB.pm.html">Peace::DB</a>
</li>
<li>
<a href="lib/Peace/Model/Application.pm.html">Peace::Model::Application</a>
</li>
<li>
<a href="lib/Peace/Model/Customer.pm.html">Peace::Model::Customer</a>
</li>
<li>
<a href="lib/Peace/Model/Developer.pm.html">Peace::Model::Developer</a>
</li>
</ul>
</body>
</html>