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