/usr/share/perl5/Pod/ProjectDocs.pm is in libpod-projectdocs-perl 0.50-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | package Pod::ProjectDocs;
use strict;
use warnings;
our $VERSION = '0.50'; # VERSION
use Moose;
use File::Spec;
use JSON;
use Pod::ProjectDocs::DocManager;
use Pod::ProjectDocs::Config;
use Pod::ProjectDocs::Parser;
use Pod::ProjectDocs::CSS;
use Pod::ProjectDocs::IndexPage;
has 'managers' => (
is => 'rw',
isa => 'ArrayRef',
default => sub { [] },
);
has 'components' => (
is => 'rw',
isa => 'HashRef',
default => sub { {} },
);
has 'config' => (
is => 'ro',
isa => 'Object',
);
sub BUILDARGS {
my ( $class, %args ) = @_;
$args{title} ||= "MyProject's Libraries";
$args{desc} ||= "manuals and libraries";
$args{lang} ||= "en";
# set absolute path to 'outroot'
$args{outroot} ||= File::Spec->curdir;
$args{outroot} = File::Spec->rel2abs( $args{outroot}, File::Spec->curdir )
unless File::Spec->file_name_is_absolute( $args{outroot} );
# set absolute path to 'libroot'
$args{libroot} ||= File::Spec->curdir;
$args{libroot} = [ $args{libroot} ] unless ref $args{libroot};
$args{libroot} = [
map {
File::Spec->file_name_is_absolute($_)
? $_
: File::Spec->rel2abs( $_, File::Spec->curdir )
} @{ $args{libroot} }
];
# check mtime by default, but can be overridden
$args{forcegen} ||= 0;
$args{nosourcecode} = 0 if !defined $args{nosourcecode};
$args{except} ||= [];
$args{except} = [ $args{except} ] unless ref $args{except};
$args{config} = Pod::ProjectDocs::Config->new(%args);
return \%args;
}
sub BUILD {
my $self = shift;
$self->components->{css} =
Pod::ProjectDocs::CSS->new( config => $self->config );
$self->add_manager( 'Perl Manuals', 'pod', Pod::ProjectDocs::Parser->new );
$self->add_manager( 'Perl Modules', 'pm', Pod::ProjectDocs::Parser->new );
$self->add_manager(
'Trigger Scripts',
[ 'cgi', 'pl' ],
Pod::ProjectDocs::Parser->new
);
return;
}
sub add_manager {
my ( $self, $desc, $suffix, $parser ) = @_;
push @{ $self->managers },
Pod::ProjectDocs::DocManager->new(
config => $self->config,
desc => $desc,
suffix => $suffix,
parser => $parser,
);
return;
}
sub gen {
my $self = shift;
foreach my $comp_key ( keys %{ $self->components } ) {
my $comp = $self->components->{$comp_key};
$comp->publish();
}
my %local_modules;
foreach my $manager ( @{ $self->managers } ) {
next if $manager->desc !~ /Perl Modules/;
for my $doc ( @{ $manager->docs() || [] } ) {
my $name = $doc->name;
my $path = $doc->get_output_path;
if ( $manager->desc eq 'Perl Modules' ) {
$local_modules{$name} = $path;
}
}
}
foreach my $manager ( @{ $self->managers } ) {
$manager->parser->local_modules( \%local_modules );
for my $doc ( @{ $manager->docs() || [] } ) {
my $html = $manager->parser->gen_html(
doc => $doc,
desc => $manager->desc,
components => $self->components,
);
if ( $self->config->forcegen || $doc->is_modified ) {
if ( !$self->config->nosourcecode ) {
$doc->copy_src();
}
$doc->publish($html);
}
}
}
my $index_page = Pod::ProjectDocs::IndexPage->new(
config => $self->config,
components => $self->components,
json => $self->get_managers_json,
);
$index_page->publish();
return;
}
sub get_managers_json {
my $self = shift;
my $js = JSON->new;
my $records = [];
foreach my $manager ( @{ $self->managers } ) {
my $record = {
desc => $manager->desc,
records => [],
};
foreach my $doc ( @{ $manager->docs } ) {
push @{ $record->{records} },
{
path => $doc->relpath,
name => $doc->name,
title => $doc->title,
};
}
if ( scalar( @{ $record->{records} } ) > 0 ) {
push @$records, $record;
}
}
# Use "canonical" to generate stable structures that can be added
# to version control systems without changing all the time.
return $js->canonical()->encode($records);
}
sub _croak {
my ( $self, $msg ) = @_;
require Carp;
Carp::croak($msg);
return;
}
1;
__END__
=encoding utf-8
=head1 NAME
Pod::ProjectDocs - generates CPAN like project documents from pod.
=head1 SYNOPSIS
#!/usr/bin/perl
use strict;
use warnings;
use Pod::ProjectDocs;
my $pd = Pod::ProjectDocs->new(
libroot => '/your/project/lib/root',
outroot => '/output/directory',
title => 'ProjectName',
);
$pd->gen();
# or use pod2projdocs on your shell
pod2projdocs -out /output/directory -lib /your/project/lib/root
=head1 DESCRIPTION
This module allows you to generates CPAN like pod pages from your modules
for your projects. It also creates an optional index page.
=head1 OPTIONS
=over 4
=item C<outroot>
output directory for the generated documentation.
=item C<libroot>
your library's (source code) root directory.
You can set single path by string, or multiple by arrayref.
my $pd = Pod::ProjectDocs->new(
outroot => '/path/to/output/directory',
libroot => '/path/to/lib'
);
or
my $pd = Pod::ProjectDocs->new(
outroot => '/path/to/output/directory',
libroot => ['/path/to/lib1', '/path/to/lib2'],
);
=item C<title>
your project's name.
=item C<desc>
description for your project.
=item C<index>
whether you want to create an index for all generated pages (0 or 1).
=item C<lang>
set this language as xml:lang (default 'en')
=item C<forcegen>
whether you want to generate HTML document even if source files are not updated (default is 0).
=item C<nosourcecode>
whether to suppress inclusion of the original source code in the generated output (default is 0).
=item C<except>
the files matches this regex won't be parsed.
Pod::ProjectDocs->new(
except => qr/^specific_dir\//,
...other parameters
);
Pod::ProjectDocs->new(
except => [qr/^specific_dir1\//, qr/^specific_dir2\//],
...other parameters
);
=back
=head1 pod2projdocs
You can use the command line script L<pod2projdocs> to generate your documentation
without creating a custom perl script.
pod2projdocs -help
=head1 SEE ALSO
L<Pod::Simple::XHTML>
=head1 AUTHORS
=over 4
=item Lyo Kato E<lt>lyo.kato@gmail.comE<gt>
=item L<Martin Gruner|https://github.com/mgruner> (current maintainer)
=back
=head1 COPYRIGHT AND LICENSE
=over 4
=item © 2005 by Lyo Kato
=item © 2018 by Martin Gruner
=back
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.5 or,
at your option, any later version of Perl 5 you may have available.
=cut
|