X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=tools%2FPM-Pod2html-snippet.pl;h=34dd8145cd0713272f6e8a05c7c6f6b1ca64dd3b;hb=a05e5d4499fb58198e463162d0385e8a156e1f03;hp=09c30bf0f497d14e54d88314286671583a0a1a2f;hpb=cbc85b7fd2b7eec3e5874daf742d523e23f60d5d;p=sdlgit%2FSDL-Site.git diff --git a/tools/PM-Pod2html-snippet.pl b/tools/PM-Pod2html-snippet.pl index 09c30bf..34dd814 100644 --- a/tools/PM-Pod2html-snippet.pl +++ b/tools/PM-Pod2html-snippet.pl @@ -7,7 +7,7 @@ use Pod::Xhtml; use File::Copy; use File::Spec::Functions qw(rel2abs splitpath splitdir catpath catdir catfile canonpath); -my $input_path = 'C:/SDL_perl/lib/pods'; +my $input_path = 'D:/dev/SDL_perl/lib/pods'; $input_path = $ARGV[0] if $ARGV[0]; my ($volume, $dirs) = splitpath(rel2abs(__FILE__)); @@ -16,8 +16,10 @@ pop(@directories); my $parent_dir = catpath($volume, catdir(@directories)); my $pages_path = catdir($parent_dir, 'pages'); my $assets_path = catdir($parent_dir, 'htdocs/assets'); -my $parser = Pod::Xhtml->new(FragmentOnly => 1, StringMode => 1); +my $parser = Pod::Xhtml->new(FragmentOnly => 1, StringMode => 1, LinkParser => new LinkResolver()); my %module_names = (); +my %thumbnails = (); +my %files = (); my $fh; read_file($input_path); @@ -26,14 +28,60 @@ read_file($input_path); open($fh, '>', File::Spec->catfile($pages_path, 'documentation.html-inc')); binmode($fh, ":utf8"); print($fh "
%s |
%s | ||
%s | %s | %s |
\s*([^<>]+)\s*<\/p>\s*<\/div>/ + ? "$1 $_" + : "UNCATEGORIZED/$_"; + $key = " $key" if $key =~ /^Core/; + $files{$key}{'path'} = $file_path; + $files{$key}{'name'} = $module_name; + $files{$key}{'desc'} = $parser->asString =~ /
\s*[^<>\-]+\-([^<>]+)\s*<\/p>\s*<\/div>/ + ? $1 + : ''; + $files{$key}{'section'} = $parser->asString =~ /
\s*([^<>]+)\s*<\/p>\s*<\/div>/
+ ? $1
+ : 'UNCATEGORIZED';
+
+ # handling images
my $image_path = $_;
$image_path =~ s/\.pod$//;
my @images = <$image_path*>;
@@ -54,32 +131,25 @@ sub read_file
foreach my $image_file (@images)
{
- if($image_file =~ /^($image_path)(_\d+){0,1}\.(jpg|jpeg|png|gif)$/)
+ if($image_file =~ /^($image_path)(_\w+){0,1}\.(jpg|jpeg|png|gif)$/)
{
my (undef, undef, $image_file_name) = splitpath($image_file);
- $image_html .= sprintf(''
- . ''
- . '', $image_file_name, $image_file_name, $image_file_name);
-
+ if($image_file_name =~ /_thumb\.(jpg|jpeg|png|gif)$/)
+ {
+ $files{$key}{'thumb'} = $image_file_name;
+ }
+ else
+ {
+ $image_html .= sprintf(''
+ . '
'
+ . '', $image_file_name, $image_file_name, $image_file_name);
+ }
+
copy($image_file, File::Spec->catfile($assets_path, $image_file_name));
}
}
- my $file_name = $_;
- $file_name =~ s/^$input_path\/*//;
- my $module_name = $file_name;
- $module_name =~ s/\//::/g;
- $module_name =~ s/(\.pm|\.pod)$//i;
- $file_name =~ s/\//-/g;
- $file_name =~ s/(\.pm|\.pod)$/.html-inc/i;
- my $file_path = $file_name;
- $file_path =~ s/\-inc$//;
- $module_names{$module_name} = $file_path;
- $file_name = File::Spec->catfile($pages_path, $file_name);
-
- $parser->parse_from_file($_); #, $file_name);
-
# modifying the html-snippet and insert the images
my $html = $parser->asString;
$html =~ s//$image_html