Subject: | Patch: view POD from scripts too |
Thanks for writing Gtk2::PodViewer.
The attached patch allows perldoc-like behaviour of searching $PATH for scripts with embedded POD. Which allows you to say:
podviewer podviewer
Cheers
Grant
--- Gtk2/PodViewer.pm 2004-09-14 00:58:56.000000000 +1200
+++ Gtk2/PodViewer.pm 2005-03-04 13:19:08.000000000 +1300
@@ -7,6 +7,7 @@
use Gtk2::PodViewer::Parser;
use vars qw($VERSION);
use Gtk2::Pango; # pango constants
+use File::Spec;
use strict;
our $VERSION = '0.08a';
@@ -278,6 +279,7 @@
return 1 if $self->load_module($name);
return 1 if $self->load_file($name);
return 1 if $self->load_function($name);
+ return 1 if $self->load_script($name);
return undef;
}
@@ -395,6 +397,18 @@
return 1;
}
+sub load_script {
+ my ($self, $script) = @_;
+ foreach my $dir (File::Spec->path()) {
+ my $file = File::Spec->catfile($dir, $script);
+ if (-T $file) { # text files only
+ $self->load_file($file);
+ return 1;
+ }
+ }
+ return undef;
+}
+
sub perlfunc {
my $self = shift;
return $self->{perlfunc} if (defined($self->{perlfunc}));