Mercurial > pub > Impl
diff _doc/make.pl @ 194:4d0e1962161c
Replaced tabs with spaces
IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
author | cin |
---|---|
date | Tue, 10 Apr 2012 20:08:29 +0400 |
parents | 47dac58691ee |
children | dacfe7c0311a |
line wrap: on
line diff
--- a/_doc/make.pl Tue Apr 10 08:13:22 2012 +0400 +++ b/_doc/make.pl Tue Apr 10 20:08:29 2012 +0400 @@ -25,8 +25,8 @@ my $dir =$OutDir; foreach my $part (@path[0..$#path-1]) { - $dir = File::Spec->catdir($dir,$part); - mkdir $dir unless -d $dir; + $dir = File::Spec->catdir($dir,$part); + mkdir $dir unless -d $dir; } open my $hPod, "<:encoding(utf-8)", $fname or die "Failed to open $fname for input: $!"; @@ -47,43 +47,43 @@ opendir my $hdir, $dirname or die "faield to open dir $dirname: $!"; foreach my $entry (readdir $hdir) { - next if grep $_ eq $entry, '.','..'; - - my $path = "$dirname/$entry"; - - print "$path"; - - if (-d $path) { - print "\n"; - local $index = exists $index->{items}{$entry} ? $index->{items}{$entry} : ($index->{items}{$entry} = {name => $entry}); - process_dir($path,@dirs,$entry); - } elsif ($entry =~ /\.(pm|pod)$/) { - print "\tprocessed\n"; - process_file($path,@dirs,$entry); - } else { - print "\tskipped\n"; - } + next if grep $_ eq $entry, '.','..'; + + my $path = "$dirname/$entry"; + + print "$path"; + + if (-d $path) { + print "\n"; + local $index = exists $index->{items}{$entry} ? $index->{items}{$entry} : ($index->{items}{$entry} = {name => $entry}); + process_dir($path,@dirs,$entry); + } elsif ($entry =~ /\.(pm|pod)$/) { + print "\tprocessed\n"; + process_file($path,@dirs,$entry); + } else { + print "\tskipped\n"; + } } } sub build_index { - my ($hout,$index) = @_; - - print $hout "\n<ul>\n"; - - if ($index->{items}) { - foreach my $itemKey (sort keys %{$index->{items}}) { - my $item = $index->{items}{$itemKey}; - print $hout "<li>"; - print $hout "<a target='content' href='$item->{url}'>" if $item->{url}; - print $hout $item->{name}; - print $hout "</a>" if $item->{url}; - build_index($hout,$item) if $item->{items}; - print $hout "</li>\n"; - } - } - - print $hout "</ul>\n"; + my ($hout,$index) = @_; + + print $hout "\n<ul>\n"; + + if ($index->{items}) { + foreach my $itemKey (sort keys %{$index->{items}}) { + my $item = $index->{items}{$itemKey}; + print $hout "<li>"; + print $hout "<a target='content' href='$item->{url}'>" if $item->{url}; + print $hout $item->{name}; + print $hout "</a>" if $item->{url}; + build_index($hout,$item) if $item->{items}; + print $hout "</li>\n"; + } + } + + print $hout "</ul>\n"; } `rm -r html`; @@ -120,8 +120,8 @@ <title>IMPL reference</title> </head> <frameset cols="20%,*"> - <frame name="toc" src="toc.html"/> - <frame name="content" src="about:blank"/> + <frame name="toc" src="toc.html"/> + <frame name="content" src="about:blank"/> </frameset> </html> FRAMES @@ -135,99 +135,99 @@ my ($self, $pod) = @_; return "<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /> \n<body bgcolor=\"#ffffff\">\n" - . $pod->content->present($self) + . $pod->content->present($self) . "</body>\n</html>\n"; } sub view_begin { - my ($self,$begin) = @_; - return code_highlight(join ("",$begin->content()),$begin->format); + my ($self,$begin) = @_; + return code_highlight(join ("",$begin->content()),$begin->format); } sub escape_html { - my %esc = ( - '&' => '&', - '>' => '>', - '<' => '<' - ); - - (my $text = shift) =~ s/([&><])/$esc{$1}/gex; - - return $text; + my %esc = ( + '&' => '&', + '>' => '>', + '<' => '<' + ); + + (my $text = shift) =~ s/([&><])/$esc{$1}/gex; + + return $text; } sub view_seq_link { - my ($self,$text) = @_; - - $text =~ s/(\w+(?:\:\:\w+)+)/ - if (my $url = $self->mk_filelink($1)) { - "<a href='$url'>$1<\/a>"; - } else { - $1; - } - /gex; - - return "<code>$text</code>"; + my ($self,$text) = @_; + + $text =~ s/(\w+(?:\:\:\w+)+)/ + if (my $url = $self->mk_filelink($1)) { + "<a href='$url'>$1<\/a>"; + } else { + $1; + } + /gex; + + return "<code>$text</code>"; } sub mk_filelink { - my ($self,$package) = @_; - - return undef unless $package; - - my @path = split /::/, $package; - - if ($path[0] eq 'IMPL') { - shift @path; - if (-f File::Spec->catfile($LibDir,@path).".pm") { - return '../'x($level-1) . File::Spec->catfile(@path).'.html'; - } - } - return undef; + my ($self,$package) = @_; + + return undef unless $package; + + my @path = split /::/, $package; + + if ($path[0] eq 'IMPL') { + shift @path; + if (-f File::Spec->catfile($LibDir,@path).".pm") { + return '../'x($level-1) . File::Spec->catfile(@path).'.html'; + } + } + return undef; } sub view_seq_code { - goto &view_seq_link; + goto &view_seq_link; } sub view_code { - my ($self,$code) = @_; - - return code_highlight($code); + my ($self,$code) = @_; + + return code_highlight($code); } sub code_highlight { - my ($text,$format) = @_; - - if ($format) { - $format =~ s/code//i; - $format =~ s/\s+//g; - } - - $format ||= 'perl'; - - return "<pre>".escape_html($text)."</pre>\n" if $format =~ /^text$/i; - - - - my ($hin,$hout); - local $/ = undef; - my $pid = eval { open2( - $hin, $hout, 'source-highlight' => ( - '--src-lang' => $format, - ) - ) } or return "<pre>".escape_html($text)."</pre>\n"; - - binmode $hout, ':encoding(utf8)'; - binmode $hin, ':encoding(utf8)'; - - print $hout $text; - - undef $hout; - - my $fragment = <$hin>; - - undef $hin; - - return $fragment; - + my ($text,$format) = @_; + + if ($format) { + $format =~ s/code//i; + $format =~ s/\s+//g; + } + + $format ||= 'perl'; + + return "<pre>".escape_html($text)."</pre>\n" if $format =~ /^text$/i; + + + + my ($hin,$hout); + local $/ = undef; + my $pid = eval { open2( + $hin, $hout, 'source-highlight' => ( + '--src-lang' => $format, + ) + ) } or return "<pre>".escape_html($text)."</pre>\n"; + + binmode $hout, ':encoding(utf8)'; + binmode $hin, ':encoding(utf8)'; + + print $hout $text; + + undef $hout; + + my $fragment = <$hin>; + + undef $hin; + + return $fragment; + }