15 |
use Frey::Pod; |
use Frey::Pod; |
16 |
|
|
17 |
extends 'Frey::PPI'; |
extends 'Frey::PPI'; |
18 |
with 'Frey::Web'; |
with 'Frey::Web', 'Frey::Storage'; |
|
with 'Frey::Storage'; |
|
19 |
|
|
20 |
=head1 DESCRIPTION |
=head1 DESCRIPTION |
21 |
|
|
110 |
sub as_markup { |
sub as_markup { |
111 |
my ( $self ) = @_; |
my ( $self ) = @_; |
112 |
|
|
|
$self->add_head( 'static/introspect.css' ); |
|
|
|
|
113 |
my ( $meta, $is_role ) = $self->class_meta; |
my ( $meta, $is_role ) = $self->class_meta; |
114 |
|
|
115 |
my $class = $self->class; |
my $class = $self->class; |
145 |
$roles = join(' ', |
$roles = join(' ', |
146 |
grep { ! m/\Q$class\E/ } # skip me |
grep { ! m/\Q$class\E/ } # skip me |
147 |
map { |
map { |
148 |
my $name = $_->name; |
my $r = ''; |
149 |
$introspect->{roles}->{$name} = {}; |
foreach my $name ( split(/\|/, $_->name) ) { |
150 |
$method_from_role->{ $_ }->{$name} = $role_nr foreach $_->get_method_list; |
$introspect->{roles}->{$name} = {}; |
151 |
$attribute_from_role->{ $_ }->{$name} = $role_nr foreach $_->get_attribute_list; |
$method_from_role->{ $_ }->{$name} = $role_nr foreach $_->get_method_list; |
152 |
|
$attribute_from_role->{ $_ }->{$name} = $role_nr foreach $_->get_attribute_list; |
153 |
qq|<a target="$name" href="/$name" title="introspect $name">$name</a>| |
|
154 |
# . qq|<sup>| . $self->dropdown( $role_nr++, $name->meta ) . qq|</sup>| |
$r .= |
155 |
. $self->dropdown( |
qq|<a target="$name" href="/$name" title="introspect $name">$name</a>| |
156 |
qq|<sup>| . $role_nr++ . qq|</sup>|, |
# . qq|<sup>| . $self->dropdown( $role_nr++, $name->meta ) . qq|</sup>| |
157 |
$name->meta |
. $self->dropdown( |
158 |
) |
qq|<sup>| . $role_nr++ . qq|</sup>|, |
159 |
; |
$name->meta |
160 |
|
) |
161 |
|
; |
162 |
|
} |
163 |
|
$r; |
164 |
} |
} |
165 |
$meta->calculate_all_roles |
$meta->calculate_all_roles |
166 |
); |
); |
254 |
|
|
255 |
my $path = $self->class_path( $class ); |
my $path = $self->class_path( $class ); |
256 |
|
|
257 |
my $pod = Frey::Pod->new( class => $class, request_url => $self->request_url )->as_markup; |
my ( $pod_toc, $pod ) = Frey::Pod->new( class => $class, request_url => $self->request_url )->as_markup; |
258 |
return $pod if $path =~ m{\.pod}; |
return $pod_toc . $pod if $path =~ m{\.pod}; |
259 |
|
|
260 |
|
warn "# ", $pod_toc ? 'toc' : '', ' ', $pod ? 'pod' : ''; |
261 |
|
|
262 |
my $Document = PPI::Document->new( $path ); |
my $Document = PPI::Document->new( $path ); |
263 |
|
|
280 |
# $source =~ s{^.*<body[^>]+>}{}s; |
# $source =~ s{^.*<body[^>]+>}{}s; |
281 |
# $source =~ s{</body.*$}{}s; |
# $source =~ s{</body.*$}{}s; |
282 |
|
|
283 |
my $runnable = join("\n", |
my $runnable = join("</dd><dd>", |
284 |
map { |
map { |
285 |
$introspect->{runnable}->{$_} = {}; |
$introspect->{runnable}->{$_} = {}; |
286 |
my $short = $_; |
my $short = $_; |
288 |
qq|<a target="$class" href="/$class/$_" title="/$class/$_">$short</a>| |
qq|<a target="$class" href="/$class/$_" title="/$class/$_">$short</a>| |
289 |
} $self->class_runnable( $class ) |
} $self->class_runnable( $class ) |
290 |
); |
); |
291 |
$runnable = "Runnable: $runnable" if $runnable; |
$runnable = "<dt>runnable</dt><dd>$runnable</dd>" if $runnable; |
292 |
|
|
293 |
my $has_tests = ''; |
my $has_tests = ''; |
294 |
my @tests = grep { defined $_ } $self->has_tests; |
my @tests = sort { lc($a) cmp lc($b) } grep { defined $_ } $self->has_tests; |
295 |
if ( @tests ) { |
if ( @tests ) { |
296 |
$has_tests = |
$has_tests |
297 |
'Test' . ( $#tests > 0 ? 's' : '' ) . ': ' . |
= qq|<dt>test| |
298 |
join("\n", map { |
. ( $#tests > 0 ? 's' : '' ) |
299 |
qq|<a target="$class" href="/Frey::Test::Runner/as_markup?test=$_">$_</a>| |
. qq|<dt><dd>| |
300 |
} @tests ); |
. join("</dd><dd>", map { |
301 |
|
qq|<a target="$class" href="/Frey::Test::Runner/as_markup?test=$_">$_</a>| |
302 |
|
} @tests ) |
303 |
|
. qq|</dd>| |
304 |
|
; |
305 |
$introspect->{tests} = [ @tests ], |
$introspect->{tests} = [ @tests ], |
306 |
} |
} |
307 |
|
|
326 |
$self->store( $introspect_path, $introspect ); |
$self->store( $introspect_path, $introspect ); |
327 |
|
|
328 |
$self->add_css(qq| |
$self->add_css(qq| |
329 |
.right { |
.frey-introspect-right { |
330 |
position: fixed; |
position: fixed; |
331 |
top: 1em; |
top: 1em; |
332 |
right: 1em; |
right: 1em; |
333 |
z-index: 10; |
z-index: 10; |
334 |
background: #fff; |
background: #ffc; |
335 |
padding: 0.2em; |
padding: 0.5em; |
336 |
border: 1px dashed #ee8; |
width: 20%; |
337 |
|
font-size: 80%; |
338 |
|
} |
339 |
|
.frey-introspect-right dl dd { |
340 |
|
margin-left: 1em; |
341 |
|
} |
342 |
|
|
343 |
|
/* fix pod */ |
344 |
|
.frey-introspect-right dd ul { |
345 |
|
padding-left: 0; |
346 |
|
} |
347 |
|
.frey-introspect-right dl ul > li { |
348 |
|
list-style: none; |
349 |
} |
} |
350 |
|); |
|); |
351 |
|
|
352 |
my $right = join('<br>', |
my $has_pod = qq| |
353 |
grep { $_ } ( |
<dt><a href="#___top" title="Skip to POD">pod</a></dt> |
354 |
$runnable, |
<dd>$pod_toc</dd> |
355 |
$has_tests, |
| if $pod_toc; |
356 |
$pod ? qq|<a class="frey-skip" href="#___top" title="Skip to POD" >pod</a>| : '', |
|
357 |
$source ? qq|<a class="frey-skip" href="#source" title="Skip to source" >source</a>| : '', |
my $has_source = qq| |
358 |
) |
<dt><a href="#source" title="Skip to source">source</a></dt> |
359 |
); |
| if $source; |
360 |
return join("\n", |
|
361 |
|
my $right = qq| |
362 |
|
<dl> |
363 |
|
$runnable |
364 |
|
$has_tests |
365 |
|
$has_pod |
366 |
|
$has_source |
367 |
|
</dl> |
368 |
|
|; |
369 |
|
|
370 |
|
|
371 |
|
return |
372 |
qq| |
qq| |
373 |
<h1>$class</h1> |
<h1>$class</h1> |
374 |
<div class="frey-introspect"> |
<div class="frey-introspect"> |
375 |
$superclasses $roles |
$superclasses $roles |
376 |
<br>$includes |
<br>$includes |
377 |
</div> |
</div> |
378 |
<div class="right"> |
<div class="frey-introspect-right"> |
379 |
$right |
$right |
380 |
</div> |
</div> |
381 |
$table |
$table |
384 |
|
|
385 |
<h1>Source</h1><a name="source"></a> |
<h1>Source</h1><a name="source"></a> |
386 |
<div class="frey-source">$source</div> |
<div class="frey-source">$source</div> |
387 |
|, |
| |
388 |
); |
; |
389 |
} |
} |
390 |
|
|
391 |
=head1 SEE ALSO |
=head1 SEE ALSO |
394 |
|
|
395 |
=cut |
=cut |
396 |
|
|
397 |
|
__PACKAGE__->meta->make_immutable; |
398 |
|
no Moose; |
399 |
|
|
400 |
1; |
1; |