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

Legend:
Removed from v.1017  
changed lines
  Added in v.1034

  ViewVC Help
Powered by ViewVC 1.1.26