129 |
|
|
130 |
=head1 OUTPUT GENERATION |
=head1 OUTPUT GENERATION |
131 |
|
|
132 |
=head2 html |
=head2 request |
133 |
|
|
134 |
$o->html( $request ); |
$o->request( $request ); |
135 |
|
|
136 |
=cut |
=cut |
137 |
|
|
138 |
sub html { |
sub request { |
139 |
my ( $self, $request ) = @_; |
my ( $self, $request ) = @_; |
140 |
|
|
141 |
$self->add_css( 'static/introspect.css' ); |
$self->add_head( 'static/introspect.css' ); |
|
warn "## css = ",dump( $self->css ); |
|
142 |
|
|
143 |
while (1) { |
while (1) { |
144 |
|
|
147 |
my $package = $self->package; |
my $package = $self->package; |
148 |
|
|
149 |
my @methods; |
my @methods; |
150 |
@methods = map { qq|<td><a href="/~/$package/$_">$_</a></td>| } $self->methods; |
@methods = map { qq|<td class="m">$_</td>| } $self->methods; |
151 |
|
|
152 |
my @attributes; |
my @attributes; |
153 |
if ( $meta->get_attribute_list ) { |
if ( $meta->get_attribute_list ) { |
155 |
my $attr = $meta->get_attribute($_); |
my $attr = $meta->get_attribute($_); |
156 |
my ( $before, $title, $after ) = ( '', '', '' ); |
my ( $before, $title, $after ) = ( '', '', '' ); |
157 |
( $before, $title, $after ) = ( '<b>', ' title="required"', '</b>' ) if $attr->is_required; |
( $before, $title, $after ) = ( '<b>', ' title="required"', '</b>' ) if $attr->is_required; |
158 |
qq|<td>$before<a href="/~/$package/?$_">$_</a>$after</td>| |
warn $attr->dump(3); |
159 |
|
foreach my $check ( qw/has_type_constraint has_handles is_weak_ref is_required is_lazy should_coerce should_auto_deref has_trigger has_documentation has_applied_traits/ ) { |
160 |
|
my $getter; |
161 |
|
|
162 |
|
$getter = $check; |
163 |
|
$getter =~ s/^has_//; |
164 |
|
|
165 |
|
if ( $attr->$check ) { |
166 |
|
if ( $getter eq $check ) { |
167 |
|
$after .= "$check"; |
168 |
|
} else { |
169 |
|
$after .= qq{<span class="frey-popdown">$check}; |
170 |
|
$after .= '<code>' . $attr->$getter->dump . '</code>' if $getter ne $check; |
171 |
|
$after .= '</span>'; |
172 |
|
} |
173 |
|
} |
174 |
|
$after .= ' '; |
175 |
|
} |
176 |
|
qq|<td class="a">$before $_</td><td>$after</td>| |
177 |
} sort $meta->get_attribute_list |
} sort $meta->get_attribute_list |
178 |
} |
} |
179 |
|
|
180 |
my $table = qq|<table><tr><th>Methods</th><th>Attributes</th></tr>|; |
my $table = qq|<table class="frey-object-browser"><tr><th class="m">Methods</th><th class="a">Attributes</th><th class="p">Properties</th></tr>|; |
181 |
while ( @methods || @attributes ) { |
while ( @methods || @attributes ) { |
182 |
my ($m,$a) = ( shift @methods, shift @attributes ); |
my ($m,$a) = ( shift @methods, shift @attributes ); |
183 |
$m ||= '<td></td>'; |
$m ||= '<td></td>'; |
186 |
} |
} |
187 |
$table .= qq|</table>|; |
$table .= qq|</table>|; |
188 |
|
|
|
my $classes = |
|
|
qq|<div class="classes">| . |
|
|
Frey::ClassBrowser->new->markup . |
|
|
qq|</div>|; |
|
|
|
|
189 |
my ( $superclasses, $roles ) = ( '<b>Role</b>', '' ); |
my ( $superclasses, $roles ) = ( '<b>Role</b>', '' ); |
190 |
if ( ! $is_role ) { |
if ( ! $is_role ) { |
191 |
if ( $meta->superclasses ) { |
if ( $meta->superclasses ) { |
192 |
$superclasses = 'Superclasses: ' . |
$superclasses = 'Superclasses: ' . |
193 |
join(', ', |
join(', ', |
194 |
map { my $s = $_->meta->name; qq|<a href="/~/$s">$s</a>| } |
map { |
195 |
|
my $name = $_->meta->name; |
196 |
|
qq|<a class="frey-popdown" href="/~/$name">$name<code>| . $_->meta->dump(2) . qq|</code></a>|; |
197 |
|
} |
198 |
#grep { $_ ne 'Moose::Object' } |
#grep { $_ ne 'Moose::Object' } |
199 |
$meta->superclasses |
$meta->superclasses |
200 |
); |
); |
204 |
if ( $meta->can('roles') ) { |
if ( $meta->can('roles') ) { |
205 |
$roles = join(', ', |
$roles = join(', ', |
206 |
grep { ! m/\Q$package\E/ } # skip me |
grep { ! m/\Q$package\E/ } # skip me |
207 |
map { my $r = $_->name; qq|<a href="/~/$r">$r</a>| } |
map { |
208 |
|
my $name = $_->name; |
209 |
|
qq|<a class="frey-popdown" href="/~/$name">$name<code>| . $name->meta->dump(2) . qq|</code></a>|; |
210 |
|
} |
211 |
$meta->calculate_all_roles |
$meta->calculate_all_roles |
212 |
); |
); |
213 |
$roles = " with roles: $roles" if $roles; |
$roles = " with roles: $roles" if $roles; |
215 |
|
|
216 |
my $pod = Frey::Pod->new( class => $package )->markup; |
my $pod = Frey::Pod->new( class => $package )->markup; |
217 |
|
|
218 |
|
use Frey::Run; |
219 |
|
my $execute = join("\n", map { qq|<a href="/$_/$package">$_</a>| } grep { $package->can($_) } Frey::Run->execute ); |
220 |
|
$execute = " execute: $execute" if $execute; |
221 |
|
|
222 |
my $html = $self->page( |
my $html = $self->page( |
223 |
title => "Introspect $package", |
title => "Introspect $package", |
224 |
body => qq|<h1>$package</h1>| |
body => qq|<h1>$package</h1>| |
225 |
. qq|$superclasses\n$roles\n| |
. qq|$superclasses\n$roles\n$execute\n| |
226 |
. ( $pod ? qq|<a href="#___top" title="Skip to POD" style="font-size: 80%; color: #aaa;">↓pod&darr</a>| : '' ) |
. ( $pod ? qq|<a href="#___top" title="Skip to POD" style="font-size: 80%; color: #aaa;">↓pod&darr</a>| : '' ) |
227 |
. qq|$table\n$pod\n$classes|, |
. qq|$table\n$pod| |
228 |
|
|
229 |
); |
); |
230 |
|
|