8 use File::Spec::Functions qw(rel2abs splitpath splitdir catpath catdir catfile canonpath);
10 my $input_path = 'C:/SDL_perl/lib/pods';
11 $input_path = $ARGV[0] if $ARGV[0];
13 my ($volume, $dirs) = splitpath(rel2abs(__FILE__));
14 my @directories = splitdir(canonpath($dirs));
16 my $parent_dir = catpath($volume, catdir(@directories));
17 my $pages_path = catdir($parent_dir, 'pages');
18 my $assets_path = catdir($parent_dir, 'htdocs/assets');
19 my $parser = Pod::Xhtml->new(FragmentOnly => 1, StringMode => 1);
20 my %module_names = ();
23 read_file($input_path);
26 open($fh, '>', File::Spec->catfile($pages_path, 'documentation.html-inc'));
27 binmode($fh, ":utf8");
28 print($fh "<div class=\"pod\">\n<h1>Documentation (latest development branch)</h1>");
29 for my $module_name (sort keys %module_names)
31 print($fh '<a href="' . $module_names{$module_name} . '">',
36 print($fh "</div>\n");
42 my @files = <$path/*>;
46 read_file($_) if(-d $_);
50 $image_path =~ s/\.pod$//;
51 my @images = <$image_path*>;
55 foreach my $image_file (@images)
57 if($image_file =~ /^($image_path)(_\d+){0,1}\.(jpg|jpeg|png|gif)$/)
59 my (undef, undef, $image_file_name) = splitpath($image_file);
61 $image_html .= sprintf('<a href="assets/%s" target="_blank">'
62 . '<img src="assets/%s" style="height: 160px" alt="%s"/>'
63 . '</a>', $image_file_name, $image_file_name, $image_file_name);
65 copy($image_file, File::Spec->catfile($assets_path, $image_file_name));
70 $file_name =~ s/^$input_path\/*//;
71 my $module_name = $file_name;
72 $module_name =~ s/\//::/g;
73 $module_name =~ s/(\.pm|\.pod)$//i;
74 $file_name =~ s/\//-/g;
75 $file_name =~ s/(\.pm|\.pod)$/.html-inc/i;
76 my $file_path = $file_name;
77 $file_path =~ s/\-inc$//;
78 $module_names{$module_name} = $file_path;
79 $file_name = File::Spec->catfile($pages_path, $file_name);
81 $parser->parse_from_file($_); #, $file_name);
83 # modifying the html-snippet and insert the images
84 my $html = $parser->asString;
85 $html =~ s/<!-- INDEX END -->/<!-- INDEX END -->$image_html<hr \/>/ if $image_html;
87 open($fh, '>', $file_name);
88 binmode($fh, ":utf8");