/[Frey]/trunk/lib/Frey/Introspect.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Introspect.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 408 by dpavlin, Tue Nov 18 12:55:32 2008 UTC revision 458 by dpavlin, Wed Nov 19 17:05:59 2008 UTC
# Line 103  sub joose { Line 103  sub joose {
103          return $out;          return $out;
104  }  }
105    
106  =head1 OUTPUT GENERATION  sub as_markup {
   
 =head2 markup  
   
   $o->markup;  
   
 =cut  
   
 sub markup {  
107          my ( $self ) = @_;          my ( $self ) = @_;
108    
109          $self->add_head( 'static/introspect.css' );          $self->add_head( 'static/introspect.css' );
# Line 166  sub markup { Line 158  sub markup {
158    
159          my @attributes;          my @attributes;
160          if ( $meta->get_attribute_list ) {          if ( $meta->get_attribute_list ) {
161          @attributes = map {                  @attributes = map {
162                          my $name = $_;                          my $name = $_;
163                          my $attr = $meta->get_attribute($name);                          my $attr = $meta->get_attribute($name);
164                            confess "$class attribute $name isn't blessed ",dump( $attr ) unless blessed $attr;
165                          warn "## attr $name ref ",ref( $attr ) if $self->debug;                          warn "## attr $name ref ",ref( $attr ) if $self->debug;
166                          my ( $before, $title, $after ) = ( '', '', '' );                          my ( $before, $title, $after ) = ( '', '', '' );
167                          ( $before, $title, $after ) = ( '<b>', ' title="required"', '</b>' ) if $attr->is_required;                          ( $before, $title, $after ) = ( '<b>', ' title="required"', '</b>' ) if $attr->can('is_required') && $attr->is_required;
168                          foreach my $check ( qw/has_type_constraint has_handles is_weak_ref is_required is_lazy should_coerce should_auto_deref has_default has_trigger has_documentation has_applied_traits/ ) {                          foreach my $check ( qw/has_type_constraint has_handles is_weak_ref is_required is_lazy should_coerce should_auto_deref has_default has_trigger has_documentation has_applied_traits/ ) {
169                                  my $getter;                                  my $getter;
170                                                                    
171                                  $getter = $check;                                  $getter = $check;
172                                  $getter =~ s/^has_//;                                  $getter =~ s/^has_//;
173                                                                    
174                                  if ( $attr->$check ) {                                  if ( $attr->can($check) && $attr->$check ) {
175                                          if ( $getter eq $check ) {                                          if ( $getter eq $check ) {
176                                                  $after .= "$check";                                                  $after .= "$check";
177                                          } else {                                          } else {
# Line 190  sub markup { Line 183  sub markup {
183                                  }                                  }
184                                  $after .= ' ';                                  $after .= ' ';
185                          }                          }
186                          my $type = $attr->has_type_constraint ? $attr->type_constraint->name : '';                          my $type = $attr->can('has_type_constraint') && $attr->has_type_constraint ? $attr->type_constraint->name : '';
187    
188                          if ( $role_attribute->{$name} ) {                          if ( $role_attribute->{$name} ) {
189                                  my ( $role_name, $nr ) = each %{ $role_attribute->{$name} };                                  my ( $role_name, $nr ) = each %{ $role_attribute->{$name} };
# Line 198  sub markup { Line 191  sub markup {
191                          }                          }
192    
193                          qq|<td class="a">$before $name</td><td class="t">$type</td><td>$after</td>|                          qq|<td class="a">$before $name</td><td class="t">$type</td><td>$after</td>|
194                  } sort $meta->get_attribute_list                  } $meta->get_attribute_list
195          }          }
196    
197          my $table = qq|<table class="frey-introspect"><tr><th class="m">Methods</th><th class="a">Attributes</th><th>Type</th><th class="p">Properties</th></tr>|;          my $table = qq|<table class="frey-introspect"><tr><th class="m">Methods</th><th class="a">Attributes</th><th>Type</th><th class="p">Properties</th></tr>|;
# Line 210  sub markup { Line 203  sub markup {
203          }          }
204          $table .= qq|</table>|;          $table .= qq|</table>|;
205    
206          my $pod = Frey::Pod->new( class => $class )->markup;          my $pod = Frey::Pod->new( class => $class )->as_markup;
207          $pod = $pod->{body} if ref($pod);          $pod = $pod->{body} if ref($pod);
208    
209          my $path = $self->class_path( $class );          my $path = $self->class_path( $class );
# Line 236  sub markup { Line 229  sub markup {
229  #       $source =~ s{</body.*$}{}s;  #       $source =~ s{</body.*$}{}s;
230    
231    
232          use Frey::Run;          my $runnable = join("\n",
233          my $runnable = join("\n", map { qq|<a href="/$class/$_">$_</a>| } grep { $class->can($_) } Frey::Run->runnable );                  map {
234                            qq|<a href="/$class/$_">$_</a>|
235                    } $self->class_runnable( $class )
236            );
237          $runnable = " runnable: $runnable" if $runnable;          $runnable = " runnable: $runnable" if $runnable;
238    
239          my $html = {          $self->title( $class );
                 title => $class,  
                 body => join("\n",  
                         qq|<h1>$class</h1>|,  
                         qq|<div class="frey-introspect">$superclasses\n$roles\n$runnable\n|,  
                         $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|$table\n$pod\n</div>\n|,  
                         qq|<h1>Source</h1><a name="source"></a><div class="frey-source">$source</div>|,  
                 ),  
         };  
240    
241          return $html;          return join("\n",
242                    qq|<h1>$class</h1>|,
243                    qq|<div class="frey-introspect">$superclasses\n$roles\n$runnable\n|,
244                    $pod    ? qq|<a class="frey-skip" href="#___top" title="Skip to POD"    >pod</a>|    : '',
245                    $source ? qq|<a class="frey-skip" href="#source" title="Skip to source" >source</a>| : '',
246                    qq|$table\n$pod\n</div>\n|,
247                    qq|<h1>Source</h1><a name="source"></a><div class="frey-source">$source</div>|,
248            );
249  }  }
250    
251  =head1 SEE ALSO  =head1 SEE ALSO

Legend:
Removed from v.408  
changed lines
  Added in v.458

  ViewVC Help
Powered by ViewVC 1.1.26