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; |
251 |
|
|
252 |
my $path = $self->class_path( $class ); |
my $path = $self->class_path( $class ); |
253 |
|
|
254 |
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; |
255 |
return $pod if $path =~ m{\.pod}; |
return $pod_toc . $pod if $path =~ m{\.pod}; |
256 |
|
|
257 |
|
warn "# ", $pod_toc ? 'toc' : '', ' ', $pod ? 'pod' : ''; |
258 |
|
|
259 |
my $Document = PPI::Document->new( $path ); |
my $Document = PPI::Document->new( $path ); |
260 |
|
|
277 |
# $source =~ s{^.*<body[^>]+>}{}s; |
# $source =~ s{^.*<body[^>]+>}{}s; |
278 |
# $source =~ s{</body.*$}{}s; |
# $source =~ s{</body.*$}{}s; |
279 |
|
|
280 |
my $runnable = join("\n", |
my $runnable = join("</dd><dd>", |
281 |
map { |
map { |
282 |
$introspect->{runnable}->{$_} = {}; |
$introspect->{runnable}->{$_} = {}; |
283 |
my $short = $_; |
my $short = $_; |
285 |
qq|<a target="$class" href="/$class/$_" title="/$class/$_">$short</a>| |
qq|<a target="$class" href="/$class/$_" title="/$class/$_">$short</a>| |
286 |
} $self->class_runnable( $class ) |
} $self->class_runnable( $class ) |
287 |
); |
); |
288 |
$runnable = "Runnable: $runnable" if $runnable; |
$runnable = "<dt>runnable</dt><dd>$runnable</dd>" if $runnable; |
289 |
|
|
290 |
my $has_tests = ''; |
my $has_tests = ''; |
291 |
my @tests = grep { defined $_ } $self->has_tests; |
my @tests = sort { lc($a) cmp lc($b) } grep { defined $_ } $self->has_tests; |
292 |
if ( @tests ) { |
if ( @tests ) { |
293 |
$has_tests = |
$has_tests |
294 |
'Test' . ( $#tests > 0 ? 's' : '' ) . ': ' . |
= qq|<dt>test| |
295 |
join("\n", map { |
. ( $#tests > 0 ? 's' : '' ) |
296 |
qq|<a target="$class" href="/Frey::Test::Runner/as_markup?test=$_">$_</a>| |
. qq|<dt><dd>| |
297 |
} @tests ); |
. join("</dd><dd>", map { |
298 |
|
qq|<a target="$class" href="/Frey::Test::Runner/as_markup?test=$_">$_</a>| |
299 |
|
} @tests ) |
300 |
|
. qq|</dd>| |
301 |
|
; |
302 |
$introspect->{tests} = [ @tests ], |
$introspect->{tests} = [ @tests ], |
303 |
} |
} |
304 |
|
|
323 |
$self->store( $introspect_path, $introspect ); |
$self->store( $introspect_path, $introspect ); |
324 |
|
|
325 |
$self->add_css(qq| |
$self->add_css(qq| |
326 |
.right { |
.frey-introspect-right { |
327 |
position: fixed; |
position: fixed; |
328 |
top: 1em; |
top: 1em; |
329 |
right: 1em; |
right: 1em; |
330 |
z-index: 10; |
z-index: 10; |
331 |
background: #fff; |
background: #ffc; |
332 |
padding: 0.2em; |
padding: 0.5em; |
333 |
border: 1px dashed #ee8; |
width: 20%; |
334 |
|
font-size: 80%; |
335 |
|
} |
336 |
|
.frey-introspect-right dl dd { |
337 |
|
margin-left: 1em; |
338 |
|
} |
339 |
|
|
340 |
|
/* fix pod */ |
341 |
|
.frey-introspect-right dd ul { |
342 |
|
padding-left: 0; |
343 |
|
} |
344 |
|
.frey-introspect-right dl ul > li { |
345 |
|
list-style: none; |
346 |
} |
} |
347 |
|); |
|); |
348 |
|
|
349 |
return join("\n", |
my $has_pod = qq| |
350 |
|
<dt><a href="#___top" title="Skip to POD">pod</a></dt> |
351 |
|
<dd>$pod_toc</dd> |
352 |
|
| if $pod_toc; |
353 |
|
|
354 |
|
my $has_source = qq| |
355 |
|
<dt><a href="#source" title="Skip to source">source</a></dt> |
356 |
|
| if $source; |
357 |
|
|
358 |
|
my $right = qq| |
359 |
|
<dl> |
360 |
|
$runnable |
361 |
|
$has_tests |
362 |
|
$has_pod |
363 |
|
$has_source |
364 |
|
</dl> |
365 |
|
|; |
366 |
|
|
367 |
|
|
368 |
|
return |
369 |
qq| |
qq| |
370 |
<h1>$class</h1> |
<h1>$class</h1> |
371 |
<div class="frey-introspect"> |
<div class="frey-introspect"> |
372 |
$superclasses $roles |
$superclasses $roles |
373 |
<br>$includes |
<br>$includes |
374 |
</div> |
</div> |
375 |
<div class="right"> |
<div class="frey-introspect-right"> |
376 |
|, |
$right |
|
join('<br>', grep { $_ } ( $runnable, $has_tests )), |
|
|
$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| |
|
377 |
</div> |
</div> |
378 |
$table |
$table |
379 |
$pod |
$pod |
381 |
|
|
382 |
<h1>Source</h1><a name="source"></a> |
<h1>Source</h1><a name="source"></a> |
383 |
<div class="frey-source">$source</div> |
<div class="frey-source">$source</div> |
384 |
|, |
| |
385 |
); |
; |
386 |
} |
} |
387 |
|
|
388 |
=head1 SEE ALSO |
=head1 SEE ALSO |