Mercurial > pub > Impl
comparison _doc/make.pl @ 65:2840c4c85db8
Application configuration improvements
Documentation
author | wizard |
---|---|
date | Tue, 16 Mar 2010 17:36:13 +0300 |
parents | 259cd3df6e53 |
children | f47f93534005 |
comparison
equal
deleted
inserted
replaced
64:259cd3df6e53 | 65:2840c4c85db8 |
---|---|
5 use Pod::POM::View::HTML; | 5 use Pod::POM::View::HTML; |
6 use File::Spec; | 6 use File::Spec; |
7 | 7 |
8 our $LibDir = '../Lib/IMPL'; | 8 our $LibDir = '../Lib/IMPL'; |
9 our $OutDir = 'html'; | 9 our $OutDir = 'html'; |
10 our $level = 0; | |
10 | 11 |
11 our $index = { name => 'root' }; | 12 our $index = { name => 'root' }; |
12 | 13 |
13 sub process_file { | 14 sub process_file { |
14 my ($fname,@path) = @_; | 15 my ($fname,@path) = @_; |
32 open my $hOut, ">:encoding(utf-8)", $fnameOut or die "Failed to open $fnameOut for output: $!"; | 33 open my $hOut, ">:encoding(utf-8)", $fnameOut or die "Failed to open $fnameOut for output: $!"; |
33 | 34 |
34 my $parser = Pod::POM->new( ); | 35 my $parser = Pod::POM->new( ); |
35 | 36 |
36 my $pom = $parser->parse_file($hPod); | 37 my $pom = $parser->parse_file($hPod); |
38 | |
39 $level = @path; | |
37 | 40 |
38 print $hOut PodViewHTML->print($pom); | 41 print $hOut PodViewHTML->print($pom); |
39 } | 42 } |
40 | 43 |
41 sub process_dir { | 44 sub process_dir { |
116 . $pod->content->present($self) | 119 . $pod->content->present($self) |
117 . "</body>\n</html>\n"; | 120 . "</body>\n</html>\n"; |
118 } | 121 } |
119 sub view_begin { | 122 sub view_begin { |
120 my ($self,$begin) = @_; | 123 my ($self,$begin) = @_; |
121 $begin->format =~ /code/i ? return "<pre>\n".join ("",$begin->text())."</pre>\n" : return $self->SUPER::view_begin($begin); | 124 $begin->format =~ /code/i ? return "<pre>\n".escape_html(join ("",$begin->text()))."</pre>\n" : return $self->SUPER::view_begin($begin); |
125 } | |
126 | |
127 sub escape_html { | |
128 my %esc = ( | |
129 '&' => '&', | |
130 '>' => '>', | |
131 '<' => '<' | |
132 ); | |
133 | |
134 (my $text = shift) =~ s/([&><])/$esc{$1}/gex; | |
135 | |
136 return $text; | |
122 } | 137 } |
123 | 138 |
124 sub view_seq_link { | 139 sub view_seq_link { |
125 my ($self,$text) = @_; | 140 my ($self,$text) = @_; |
126 | 141 |
127 $text->text =~ /(?:(\w+)\s+)(\w+(?:\:\:\w+)*)/; | 142 if ($text =~ /^\s*(?:(\w+)\s+)?(\w+(?:\:\:\w+)+)\s*$/) { |
128 | 143 |
144 my ($keyword, $package) = ($1 || '',$2); | |
145 | |
146 my @path = split /::/, $package; | |
147 | |
148 pop @path if $keyword; | |
149 shift @path if uc $path[0] eq 'IMPL'; | |
150 | |
151 if (-f File::Spec->catfile($LibDir,@path).".pm") { | |
152 return '<code><a href="'. '../'x($level-1) . File::Spec->catfile(@path) .'.html">'.$text.'</a></code>'; | |
153 } | |
154 | |
155 } elsif ($text =~ /^\s*(\w+(?:\:\:\w+)+)\s*->\s*(\w+)\s*$/) { | |
156 my ($package,$member) = ($1,$2); | |
157 | |
158 my @path = split /::/, $package; | |
159 shift @path; | |
160 | |
161 if (-f File::Spec->catfile($LibDir,@path).".pm") { | |
162 return '<code><a href="'. '../'x($level-1) . File::Spec->catfile(@path) .'.html">'.$text.'</a></code>'; | |
163 } | |
164 } | |
129 | 165 |
166 return "<code>$text</code>"; | |
130 } | 167 } |
168 | |
169 sub view_seq_code { | |
170 goto &view_seq_link; | |
171 } |