Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
removed PDL::Pod:: classes in favor of core modules Pod::
Further changed calling implementation of overriden functions "command", "textblock" and "verbatim" and a few internal methods
Also removed StrHandle and NullHandle classes in favor of opening handles to strings
  • Loading branch information
jberger committed Jan 3, 2013
1 parent 5df755c commit 6245954
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 1,759 deletions.
71 changes: 22 additions & 49 deletions Doc/Doc.pm
@@ -1,41 +1,11 @@
# the following two packages can be used to collect podparser
# output into a string or simulate a portable null device

package StrHandle;

sub new {
my $type = shift;
my $this = bless {},$type;
$this->{Text} = "";
return $this;
}

sub print {
my $this = shift;
$this->{Text} .= "@_";
}

sub text {
$_[0]->{Text} .= $_[1] if $#_ > 0;
return $_[0]->{Text};
}


package NullHandle;

@ISA = qw/ StrHandle/;

sub print {} # do nothing


# the filter for the PDL pod format (which is a valid general perl
# pod format but with special interpretation of some =for directives)

package PDL::PodParser;
use PDL::Core '';
use PDL::Pod::Parser;
use Pod::Select;

@ISA = qw(PDL::Pod::Parser);
@ISA = qw(Pod::Select);

%Title = ('Example' => 'Example',
'Ref' => 'Reference',
Expand All @@ -46,21 +16,22 @@ use PDL::Pod::Parser;
);

sub new {
my ($type) = @_;
my $parser = new PDL::Pod::Parser;
my $class = shift;
my $parser = $class->SUPER::new(@_);
bless $parser,$class; # just in case

$parser->select("METHODS|OPERATORS|CONTRUCTORS|FUNCTIONS|NAME");
$parser->{CURFUNC} = undef;
$parser->{SYMHASH} = {};
$parser->{INBLOCK} = 0;
$parser->{Mode} = "";
$parser->{verbose} = 0;
$parser->{NAME} = 'UNKNOWN';
bless $parser,$type;
return $parser;
}

sub command {
my ($this,$cmd,$txt,$sep) = @_;
my ($this,$cmd,$txt,$line_num,$pod_para) = @_;
$this->{Parmode} = 'Body';

if ($cmd eq 'head1') {
Expand Down Expand Up @@ -94,14 +65,14 @@ sub command {
print "\n\tSignature: $sig\n" if defined $sig && $this->{verbose};
$this->{CURFUNC} = $name;
} elsif ($cmd eq 'for') {
$this->check_for_mode($txt,$sep) if $cmd eq 'for';
$this->check_for_mode($txt,$pod_para) if $cmd eq 'for';
}
local $this->{Parmode} = 'Body';
$this->SUPER::command($cmd,$txt,$sep);
$this->SUPER::command($cmd,$txt,$line_num,$pod_para);
}
sub check_for_mode {
my ($this,$txt,$sep) = @_;
my ($this,$txt,$pod_para) = @_;
if ($txt =~ /^(sig|example|ref|opt|usage|bad|body)/i) {
$this->{Parmode} = ucfirst lc $1;
print "switched now to '$1' mode\n" if $this->{VERBOSE};
Expand All @@ -111,10 +82,11 @@ sub check_for_mode {
}
sub textblock {
my ($this,$txt) = @_;
my $this = shift;
my $txt = shift;
$this->checkmode($txt);
local $this->{INBLOCK} = 1;
$this->SUPER::textblock($txt);
$this->SUPER::textblock($txt,@_);
$this->{Parmode} = 'Body'; # and reset parmode
}
Expand All @@ -141,9 +113,10 @@ sub checkmode {
}
sub verbatim {
my ($this,$txt) = @_;
my $this = shift;
my $txt = shift;
$this->checkmode($txt,1);
$this->SUPER::verbatim($txt);
$this->SUPER::verbatim($txt,@_);
}
# this needs improvement
Expand Down Expand Up @@ -677,7 +650,7 @@ sub scan {
my $infile = new IO::File $file;
# XXXX convert to absolute path
# my $outfile = '/tmp/'.basename($file).'.pod';
my $outfile = new NullHandle;
open my $outfile, '>', \(my $outfile_text);
# Handle RPM etc. case where we are building away from the final
# location. Alright it's a hack - KGB
Expand Down Expand Up @@ -707,11 +680,11 @@ sub scan {
# and one can now find modules with 'apropos'
$infile = new IO::File $file;
$outfile = new StrHandle;
$outfile_text = '';
$parser = new PDL::PodParser;
$parser->select('NAME');
$parser->parse_from_filehandle($infile,$outfile);
my @namelines = split("\n",$outfile->{Text});
my @namelines = split("\n",$outfile_text);
my ($name,$does);
for (@namelines) {
if (/^(PDL) (-) (.*)/ or /\s*(PDL::[\w:]*)\s*(-*)?\s*(.*)\s*$/) {
Expand Down Expand Up @@ -798,14 +771,14 @@ sub funcdocs_fromfile {
sub extrdoc {
my ($func,$file) = @_;
my $out = new StrHandle;
open my $out, '>', \(my $out_text);
funcdocs_fromfile($func,$file,$out);
return $out->text;
return $out_text;
}
sub getfuncdocs {
my ($func,$in,$out) = @_;
my $parser = new PDL::Pod::Parser;
my $parser = Pod::Select->new;
# $parser->select("\\(METHODS\\|OPERATORS\\|CONSTRUCTORS\\|FUNCTIONS\\|METHODS\\)/$func(\\(.*\\)*\\s*");
foreach my $foo(qw/FUNCTIONS OPERATORS CONSTRUCTORS METHODS/) {
seek $in,0,0;
Expand Down
5 changes: 3 additions & 2 deletions Doc/Doc/Perldl.pm
Expand Up @@ -39,11 +39,12 @@ use vars qw(@ISA @EXPORT);
@EXPORT = qw( apropos aproposover usage help sig badinfo whatis );

use PDL::Doc;
use Pod::Select;
use IO::File;
use Pod::PlainText;

$PDL::onlinedoc = undef;
$PDL::onlinedoc = new PDL::Doc (FindStdFile());
$PDL::onlinedoc = PDL::Doc->new(FindStdFile());

use PDL::Config;
my $bvalflag = $PDL::Config{WITH_BADVAL} || 0;
Expand Down Expand Up @@ -266,7 +267,7 @@ sub finddoc {
} else {
if(defined $m->[1]{CustomFile}) {

my $parser= new PDL::Pod::Parser;
my $parser= Pod::Select->new;
print $out "=head1 Autoload file \"".$m->[1]{CustomFile}."\"\n\n";
$parser->parse_from_file($m->[1]{CustomFile},$out);
print $out "\n\n=head2 Docs from\n\n".$m->[1]{CustomFile}."\n\n";
Expand Down
18 changes: 0 additions & 18 deletions Doc/Pod/Makefile.PL

This file was deleted.

0 comments on commit 6245954

Please sign in to comment.