diff --git a/bin/generate_documentation.pl b/bin/generate_documentation.pl
index aa9b906..b9cc9df 100644
--- a/bin/generate_documentation.pl
+++ b/bin/generate_documentation.pl
@@ -9,6 +9,8 @@ use Data::Dumper;
use Path::Tiny qw/path/;
use Mojo::Template;
+use Mojo::DOM;
+use File::pushd;
my $current_dir = path(__FILE__)->parent->parent->child('lib');
@@ -19,9 +21,7 @@ $current_dir->visit(
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';
+ '-o', 'doc/' . $path . '.html', '--recurse';
}
},
{ recurse => 1 }
@@ -39,7 +39,29 @@ $documentation_path->visit(
return;
}
$modules{ $path =~ s{^.*/lib/}{}r =~ s/\.pm\.html$//r =~ s{/}{::}gr } =
- ''.$path=~s/doc\///r;
+ $path
+ },
+ { recurse => 1 },
+);
+$documentation_path->visit(
+ sub {
+ my ( $path, $state ) = @_;
+ if ( !-f $path ) {
+ return;
+ }
+ if ( $path !~ /\.pm\.html$/ ) {
+ return;
+ }
+ my $html = Mojo::DOM->new($path->slurp_utf8);
+ for my $a ($html->find('a')->each) {
+ next if $a->{href};
+ if (exists $modules{$a->text}) {
+ $a->{href} = relativize_path($path, $modules{$a->text});
+ next;
+ }
+ $a->{href} = "https://metacpan.org/pod/@{[$a->text]}";
+ }
+ $path->spew_utf8(''.$html);
},
{ recurse => 1 },
);
@@ -47,6 +69,7 @@ $documentation_path->visit(
my $mojo_template = Mojo::Template->new;
my $html = $mojo_template->render(<<'EOF', \%modules);
% my ($modules) = @_;
+% use Path::Tiny;
@@ -56,7 +79,7 @@ my $html = $mojo_template->render(<<'EOF', \%modules);
@@ -65,3 +88,9 @@ my $html = $mojo_template->render(<<'EOF', \%modules);
EOF
$documentation_path->child('index.html')->spew_utf8($html);
+
+sub relativize_path {
+ my $current_path = $_[0];
+ my $foreign_path = $_[1];
+ return $foreign_path->relative($current_path->parent);
+}
diff --git a/doc/lib/Peace.pm.html b/doc/lib/Peace.pm.html
index 255e1f0..5dbaae7 100644
--- a/doc/lib/Peace.pm.html
+++ b/doc/lib/Peace.pm.html
@@ -3,8 +3,8 @@
Peace - Onlie GNU/Linux flatpak apps store.
-
-
+
+
diff --git a/doc/lib/Peace/Controller/User.pm.html b/doc/lib/Peace/Controller/User.pm.html
index 21f9514..01956d4 100644
--- a/doc/lib/Peace/Controller/User.pm.html
+++ b/doc/lib/Peace/Controller/User.pm.html
@@ -2,9 +2,9 @@
-
-
-
+
+
+
diff --git a/doc/lib/Peace/DAO/Application.pm.html b/doc/lib/Peace/DAO/Application.pm.html
index 21f9514..01956d4 100644
--- a/doc/lib/Peace/DAO/Application.pm.html
+++ b/doc/lib/Peace/DAO/Application.pm.html
@@ -2,9 +2,9 @@
-
-
-
+
+
+
diff --git a/doc/lib/Peace/DAO/Customer.pm.html b/doc/lib/Peace/DAO/Customer.pm.html
index 21f9514..01956d4 100644
--- a/doc/lib/Peace/DAO/Customer.pm.html
+++ b/doc/lib/Peace/DAO/Customer.pm.html
@@ -2,9 +2,9 @@
-
-
-
+
+
+
diff --git a/doc/lib/Peace/DAO/Developer.pm.html b/doc/lib/Peace/DAO/Developer.pm.html
index 21f9514..01956d4 100644
--- a/doc/lib/Peace/DAO/Developer.pm.html
+++ b/doc/lib/Peace/DAO/Developer.pm.html
@@ -2,9 +2,9 @@
-
-
-
+
+
+
diff --git a/doc/lib/Peace/DB.pm.html b/doc/lib/Peace/DB.pm.html
index b0f6fe2..7988ff2 100644
--- a/doc/lib/Peace/DB.pm.html
+++ b/doc/lib/Peace/DB.pm.html
@@ -3,8 +3,8 @@
Peace::DB - Database handler generator for the Peace shop.
-
-
+
+
@@ -62,7 +62,7 @@ my $dbh = Peace::DB->dbh( config => $config );
SEE ALSO
-DBI, DBD::Pg, Peace
+DBI, DBD::Pg, Peace
diff --git a/doc/lib/Peace/Model/Application.pm.html b/doc/lib/Peace/Model/Application.pm.html
index 3cf6c35..ae22365 100644
--- a/doc/lib/Peace/Model/Application.pm.html
+++ b/doc/lib/Peace/Model/Application.pm.html
@@ -3,8 +3,8 @@
Peace::Model::Application - The application object representation.
-
-
+
+
@@ -129,7 +129,7 @@ $application->url($url);
$application->developer($developer);
-Allows to retrieve and set the application's developer which is a Peace::Model::Developer.
+Allows to retrieve and set the application's developer which is a Peace::Model::Developer.
price
@@ -165,7 +165,7 @@ $application->verified($verified);
SEE ALSO
-Peace::Model::Developer, Peace::DAO::Application
+Peace::Model::Developer, Peace::DAO::Application
diff --git a/doc/lib/Peace/Model/Customer.pm.html b/doc/lib/Peace/Model/Customer.pm.html
index f65325e..0f724b4 100644
--- a/doc/lib/Peace/Model/Customer.pm.html
+++ b/doc/lib/Peace/Model/Customer.pm.html
@@ -3,8 +3,8 @@
Peace::Model::Customer - The customer object representation.
-
-
+
+
@@ -96,7 +96,7 @@ $customer->stripe_id($stripe_id);
SEE ALSO
-Peace::DAO::Customer
+Peace::DAO::Customer
diff --git a/doc/lib/Peace/Model/Developer.pm.html b/doc/lib/Peace/Model/Developer.pm.html
index be72ed7..ad3f151 100644
--- a/doc/lib/Peace/Model/Developer.pm.html
+++ b/doc/lib/Peace/Model/Developer.pm.html
@@ -3,8 +3,8 @@
Peace::Model::Developer - The developer object representation.
-
-
+
+
@@ -83,7 +83,7 @@
my $applications = $developer->applications;
-Allows to retrieve the developer's applications which is a arrayref of Peace::Model::Application.
+Allows to retrieve the developer's applications which is a arrayref of Peace::Model::Application.
uuid
@@ -157,7 +157,7 @@ $developer->verified($verified);
SEE ALSO
-Peace::DAO::Developer, Peace::Model::Application
+Peace::DAO::Developer, Peace::Model::Application