tools
[sdlgit/SDL-Site.git] / tools / PM-Pod2html-snippet.pl
CommitLineData
4e1ad99d 1#!/usr/bin/env perl
2
3use strict;
4use warnings;
5
6use File::Spec;
7use Pod::Xhtml;
8
9#system('git pull');
10
11my $input_path = 'C:/SDL_perl/lib/pods';
12my $output_path = 'F:/htdocs/SDL-Site/pages';
13my $parser = Pod::Xhtml->new(FragmentOnly => 1);
14my %module_names = ();
15my $fh;
16
17read_file($input_path);
18
19# creating index file
20open($fh, '>', File::Spec->catfile($output_path, 'documentation.html-inc'));
21binmode($fh, ":utf8");
22print($fh "<div class=\"pod\">\n<h1>Documentation (latest development branch)</h1>");
23for my $module_name (sort keys %module_names)
24{
25 print($fh '<a href="' . $module_names{$module_name} . '">',
26 $module_name,
27 '</a><br />'
28 );
29}
30print($fh "</div>\n");
31close($fh);
32
33sub read_file
34{
35 my $path = shift;
36 my @files = <$path/*>;
37
38 foreach(@files)
39 {
40 read_file($_) if(-d $_);
41
42 if($_ =~ /\.pod$/i)
43 {
44 my $file_name = $_;
45 $file_name =~ s/^$input_path\/*//;
46 my $module_name = $file_name;
47 $module_name =~ s/\//::/g;
48 $module_name =~ s/(\.pm|\.pod)$//i;
49 $file_name =~ s/\//-/g;
50 $file_name =~ s/(\.pm|\.pod)$/.html-inc/i;
51 my $file_path = $file_name;
52 $file_path =~ s/\-inc$//;
53 $module_names{$module_name} = $file_path;
54 $file_name = File::Spec->catfile($output_path, $file_name);
55
56 $parser->parse_from_file($_, $file_name);
57 }
58 }
59}