Commit | Line | Data |
b3ef54ec |
1 | #!/usr/bin/env perl |
2 | |
3 | use strict; |
4 | use warnings; |
35f7648e |
5 | use Carp; |
b3ef54ec |
6 | use Pod::Xhtml; |
de71a5b8 |
7 | use File::Spec::Functions qw(rel2abs splitpath splitdir catpath catdir catfile canonpath); |
4e1ad99d |
8 | |
de71a5b8 |
9 | my $input_path = 'C:/SDL_perl/lib/pods'; |
35f7648e |
10 | $input_path = $ARGV[0] if $ARGV[0]; |
4e1ad99d |
11 | |
de71a5b8 |
12 | my ($volume, $dirs) = splitpath(rel2abs(__FILE__)); |
13 | my @directories = splitdir(canonpath($dirs)); |
14 | pop(@directories); |
15 | my $parent_dir = catpath($volume, catdir(@directories)); |
16 | my $output_path = catdir($parent_dir, 'pages'); |
17 | my $parser = Pod::Xhtml->new(FragmentOnly => 1); |
18 | my %module_names = (); |
b3ef54ec |
19 | my $fh; |
20 | |
21 | read_file($input_path); |
22 | |
23 | # creating index file |
24 | open($fh, '>', File::Spec->catfile($output_path, 'documentation.html-inc')); |
25 | binmode($fh, ":utf8"); |
26 | print($fh "<div class=\"pod\">\n<h1>Documentation (latest development branch)</h1>"); |
27 | for my $module_name (sort keys %module_names) |
28 | { |
29 | print($fh '<a href="' . $module_names{$module_name} . '">', |
30 | $module_name, |
31 | '</a><br />' |
32 | ); |
33 | } |
34 | print($fh "</div>\n"); |
35 | close($fh); |
36 | |
37 | sub read_file |
38 | { |
39 | my $path = shift; |
40 | my @files = <$path/*>; |
41 | |
42 | foreach(@files) |
43 | { |
44 | read_file($_) if(-d $_); |
35f7648e |
45 | carp "Invalid directory $_" if !(-d $_); |
b3ef54ec |
46 | if($_ =~ /\.pod$/i) |
47 | { |
48 | my $file_name = $_; |
49 | $file_name =~ s/^$input_path\/*//; |
50 | my $module_name = $file_name; |
51 | $module_name =~ s/\//::/g; |
52 | $module_name =~ s/(\.pm|\.pod)$//i; |
53 | $file_name =~ s/\//-/g; |
54 | $file_name =~ s/(\.pm|\.pod)$/.html-inc/i; |
55 | my $file_path = $file_name; |
56 | $file_path =~ s/\-inc$//; |
57 | $module_names{$module_name} = $file_path; |
58 | $file_name = File::Spec->catfile($output_path, $file_name); |
59 | |
60 | $parser->parse_from_file($_, $file_name); |
61 | } |
62 | } |
63 | } |