114 |
my @methods = grep { ! defined($attr->{$_}) } $class->get_method_list; |
my @methods = grep { ! defined($attr->{$_}) } $class->get_method_list; |
115 |
warn "# methods = ",dump( @methods ) if $self->debug; |
warn "# methods = ",dump( @methods ) if $self->debug; |
116 |
|
|
117 |
return @methods; |
return sort @methods; |
118 |
} |
} |
119 |
|
|
120 |
use Frey::ClassLoader; |
use Frey::ClassLoader; |
138 |
|
|
139 |
while (1) { |
while (1) { |
140 |
|
|
|
my $js = $self->head_javascript; |
|
|
$js .= << '__END_OF_JS__'; |
|
|
<script type="text/javascript"> |
|
|
joose.loadComponents("../lib") |
|
|
|
|
|
function $(id) { |
|
|
return document.getElementById(id) |
|
|
} |
|
|
|
|
|
</script> |
|
|
__END_OF_JS__ |
|
|
|
|
141 |
my ( $class, $meta, $is_role ) = $self->load_package; |
my ( $class, $meta, $is_role ) = $self->load_package; |
142 |
|
|
143 |
my $methods; |
my $package = $self->package; |
144 |
if ( $class->can('meta') ) { |
|
145 |
$methods = dom2html( |
my @methods; |
146 |
ul => [ |
@methods = map { qq|<td><a href="/~/$package/$_">$_</a></td>| } $self->methods if $class->can('meta'); |
|
map { ( |
|
|
li => [ a => { href => '/~/' . $self->package . '/' . $_ } => [ $_ ] ] |
|
|
) } $self->methods |
|
|
] |
|
|
); |
|
|
$methods = "<h2>Methods</h2>$methods" if $methods; |
|
|
} else { |
|
|
$methods = '<b>not introspectable</b>'; |
|
|
} |
|
147 |
|
|
148 |
my $attributes; |
my @attributes; |
149 |
if ( $class->get_attribute_list ) { |
if ( $class->get_attribute_list ) { |
150 |
$attributes = dom2html( |
@attributes = map { |
151 |
table => [ |
my $attr = $class->get_attribute($_); |
152 |
map { |
# warn "## $_ ", $attr->is_required ? 'required' : 'optional'; |
153 |
my $attr = $class->get_attribute($_); |
qq|<td><a href="/~/$package/$_?">$_</a></td><td>| . |
154 |
warn "## $_ ", $attr->is_required ? 'required' : 'optional'; |
( $attr->is_required ? ' <b>required</b>' : '' ) . |
155 |
( tr => [ |
qq|</td>|; |
156 |
td => [ a => { href => '/~/' . $self->package . '/' . $_ } => [ $_ ] ], |
} sort $class->get_attribute_list |
|
td => [ $attr->is_required ? ' <b>required</b>' : '' ], |
|
|
] ) |
|
|
} $class->get_attribute_list |
|
|
], |
|
|
); |
|
|
$attributes = "<h2>Attributes</h2>$attributes" if $attributes; |
|
|
} else { |
|
|
$attributes = '<b>no attributes</b>'; |
|
157 |
} |
} |
158 |
|
|
159 |
|
my $table = qq|<table><tr><th>Methods</th><th>Attributes</th></tr>|; |
160 |
|
while ( @methods || @attributes ) { |
161 |
|
my ($m,$a) = ( shift @methods, shift @attributes ); |
162 |
|
$m ||= '<td></td>'; |
163 |
|
$a ||= '<td></td>'; |
164 |
|
$table .= qq|<tr>$m$a</tr>|; |
165 |
|
} |
166 |
|
$table .= qq|</table>|; |
167 |
|
|
168 |
my $html = dom2html( |
my $classes = |
169 |
html => [ |
qq|<div class="classes">| . |
170 |
head => [ |
Frey::ClassBrowser->new->markup . |
171 |
link => { rel=>"stylesheet", href=>"/static/app.css", type=>"text/css", media=>"screen" }, |
qq|</div>|; |
172 |
$js, |
|
173 |
title => [ 'Introspect ', $self->package ], |
$self->add_css( 'static/introspect.css' ); |
174 |
], |
|
175 |
body => [ |
warn "## css = ",dump( $self->css ); |
176 |
h1 => [ $self->package ], |
|
177 |
$methods, |
my $superclasses = 'Role'; |
178 |
$attributes, |
$superclasses = 'Superclasses: ' . join(', ', |
179 |
], |
map { |
180 |
] |
my $s = $_->meta->name; |
181 |
|
qq|<a href="/~/$s">$s</a>| |
182 |
|
} |
183 |
|
#grep { $_ ne 'Moose::Object' } |
184 |
|
$meta->superclasses |
185 |
|
) if ! $is_role && $meta->superclasses; |
186 |
|
|
187 |
|
my $html = $self->page( |
188 |
|
title => "Introspect $package", |
189 |
|
body => "<h1>$package</h1>$superclasses\n$table\n$classes", |
190 |
); |
); |
191 |
|
|
192 |
$request->print($html); |
$request->print($html); |