/[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 358 by dpavlin, Sun Nov 16 16:36:53 2008 UTC revision 393 by dpavlin, Tue Nov 18 00:55:56 2008 UTC
# Line 8  use Data::Dump qw/dump/; Line 8  use Data::Dump qw/dump/;
8  use File::Slurp;  use File::Slurp;
9  use List::Util;  use List::Util;
10    
11    use PPI;
12    use PPI::HTML;
13    
14  use lib 'lib';  use lib 'lib';
15    
16  extends 'Frey::ClassLoader';  extends 'Frey::ClassLoader';
# Line 185  sub markup { Line 188  sub markup {
188          @attributes = map {          @attributes = map {
189                          my $name = $_;                          my $name = $_;
190                          my $attr = $meta->get_attribute($name);                          my $attr = $meta->get_attribute($name);
191                          warn "## ref attr: ",ref( $attr );                          warn "## attr $name ref ",ref( $attr ) if $self->debug;
192                          my ( $before, $title, $after ) = ( '', '', '' );                          my ( $before, $title, $after ) = ( '', '', '' );
193                          ( $before, $title, $after ) = ( '<b>', ' title="required"', '</b>' ) if $attr->is_required;                          ( $before, $title, $after ) = ( '<b>', ' title="required"', '</b>' ) if $attr->is_required;
 warn $attr->dump(3);  
194                          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/ ) {
195                                  my $getter;                                  my $getter;
196                                                                    
# Line 228  warn $attr->dump(3); Line 230  warn $attr->dump(3);
230          $table .= qq|</table>|;          $table .= qq|</table>|;
231    
232          my $pod = Frey::Pod->new( class => $class )->markup;          my $pod = Frey::Pod->new( class => $class )->markup;
233            $pod = $pod->{body} if ref($pod);
234    
235            my $Document = PPI::Document->new( $self->class_path( $class ) );
236    
237            # Create a reusable syntax highlighter
238            my $Highlight = PPI::HTML->new(
239    #               line_numbers => 1,
240    #               page => 1,
241    #               colors => {
242    #                       line_number => '#CCCCCC',
243    #                       number      => '#990000',
244    #               },
245            );
246    
247            # Spit out the HTML
248            my $source = $Highlight->html( $Document );
249    
250    #       $source =~ s{^.*<body[^>]+>}{}s;
251    #       $source =~ s{</body.*$}{}s;
252    
253          use Frey::Run;          use Frey::Run;
254          my $runnable = join("\n", map { qq|<a href="/$class/$_">$_</a>| } grep { $class->can($_) } Frey::Run->runnable );          my $runnable = join("\n", map { qq|<a href="/$class/$_">$_</a>| } grep { $class->can($_) } Frey::Run->runnable );
255          $runnable = " runnable: $runnable" if $runnable;          $runnable = " runnable: $runnable" if $runnable;
256    
257          my $html = {          my $html = {
258                  title => "Introspect $class",                  title => $class,
259                  body => qq|<h1>$class</h1>|                  body => join("\n",
260                          . qq|<div class="frey-introspect">$superclasses\n$roles\n$runnable\n|                          qq|<h1>$class</h1>|,
261                          . ( $pod ? qq|<a href="#___top" title="Skip to POD" style="font-size: 80%; color: #aaa;">&darr;pod&darr</a>| : '' )                          qq|<div class="frey-introspect">$superclasses\n$roles\n$runnable\n|,
262                          . qq|$table\n$pod</div>|                          $pod    ? qq|<a class="frey-skip" href="#___top" title="Skip to POD"    >pod</a>|    : '',
263                            $source ? qq|<a class="frey-skip" href="#source" title="Skip to source" >source</a>| : '',
264                            qq|$table\n$pod\n</div>\n|,
265                            qq|<h1>Source</h1><a name="source"></a><div class="frey-source">$source</div>|,
266                    ),
267          };          };
268    
269          return $html;          return $html;

Legend:
Removed from v.358  
changed lines
  Added in v.393

  ViewVC Help
Powered by ViewVC 1.1.26