Skip to content

Commit

Permalink
Addresses #188 by fixing some issue with Pod2Wiki generator/submitter.
Browse files Browse the repository at this point in the history
  • Loading branch information
drn05r committed Dec 15, 2021
1 parent 2c5e2d8 commit b73512a
Showing 1 changed file with 61 additions and 16 deletions.
77 changes: 61 additions & 16 deletions perl_lib/EPrints/Test/Pod2Wiki.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
package EPrints::Test::Pod2Wiki;
######################################################################
#
# EPrints::Test::Pod2Wiki
#
######################################################################
#
#
######################################################################

=pod
=for Pod2Wiki
Expand All @@ -14,7 +23,7 @@ Pages generated by this module have Pod2Wiki markers inserted. These markers are
==SYNOPSIS==
use EPrints::Test::Pod2Wiki;
my $p = EPrints::Test::Pod2Wiki->new(
wiki_index => "http://wiki.foo.org/index.php",
wiki_api => "http://wiki.foo.org/api.php",
username => "johnd",
password => "xiPi00",
);
Expand Down Expand Up @@ -44,7 +53,7 @@ The rest of this page concerns the I<EPrints::Test::Pod2Wiki> module.
use EPrints::Test::Pod2Wiki;
my $p = EPrints::Test::Pod2Wiki->new(
wiki_index => "http://wiki.foo.org/index.php",
wiki_api => "http://wiki.foo.org/api.php",
username => "johnd",
password => "xiPi00",
);
Expand All @@ -57,10 +66,10 @@ This module enables the integration of EPrints POD (documentation) and MediaWiki
=head1 METHODS
=over 4
=cut

package EPrints::Test::Pod2Wiki;

use Pod::Parser;
@ISA = qw( Pod::Parser );

Expand All @@ -78,15 +87,21 @@ my $PREFIX = "Pod2Wiki=";
my $END_PREFIX = "Edit below this comment";
my $STYLE = "background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; ";

=item EPrints::Test::Pod2Wiki->new( ... )
######################################################################
=pod
=over 4
=item EPrints::Test::Pod2Wiki->new( $class, %opts )
Create a new Pod2Wiki parser. Required options:
wiki_index - URL of the MediaWiki "index.php" page
wiki_api - URL of the MediaWiki "api.php" page
username - MediaWiki username
password - MediaWiki password
=cut
######################################################################

sub new
{
Expand All @@ -107,11 +122,15 @@ sub new
return $self;
}

######################################################################
=pod
=item $ok = $pod->update_page( $package_name )
Update the MediaWiki page for $package_name.
=cut
######################################################################

sub update_page
{
Expand Down Expand Up @@ -211,7 +230,7 @@ sub _p2w_preamble
my( $self, $package_name, $title ) = @_;

my $blurb = <<EOC;
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the '$PREFIX*' and '$END_PREFIX' comments will be lost.
This page has been automatically generated from the EPrints 3.4 source. Any wiki changes made between the '$PREFIX*' and '$END_PREFIX' comments will be lost.
EOC

my $sort_key = uc($package_name);
Expand All @@ -238,7 +257,7 @@ EOC
"{{API:Source|file=$file|package_name=$package_name}}",
"[[Category:API|$sort_key]]",
($parent ? "[[Category:API:$parent|$sort_key]]" : ()),
($selfcat ? "[[Category:API:$selfcat|$sort_key]]" : ()),
# ($selfcat ? "[[Category:API:$selfcat|$sort_key]]" : ()),
"<div>",
"<!-- $END_PREFIX -->\n\n\n",
);
Expand Down Expand Up @@ -367,11 +386,15 @@ sub _p2w_add_uncovered
-name => "back" ) );
}

=item $parser->command( ... )
######################################################################
=pod
=item $parser->command( $cmd, $text, $line_num, $pod_para )
L<Pod::Parser> callback.
=cut
######################################################################

sub command
{
Expand Down Expand Up @@ -417,6 +440,11 @@ sub command
{
$self->{_p2w_methods} = $self->{_p2w_head_depth};
}
elsif( $ref eq "copyright" )
{
$self->{_p2w_methods} = 0;
push @{$self->{_out}}, "{{API:Copyright}}\n";
}
elsif( $self->{_p2w_methods} == $self->{_p2w_head_depth} )
{
$self->{_p2w_methods} = 0;
Expand Down Expand Up @@ -478,11 +506,15 @@ sub command
}
}

=item $parser->verbatim( ... )
######################################################################
=pod
=item $parser->verbatim( $text, $line_num, $pod_para )
L<Pod::Parser> callback.
=cut
######################################################################

sub verbatim
{
Expand All @@ -497,11 +529,15 @@ sub verbatim
push @{$self->{_out}}, $text;
}

=item $parser->textblock( ... )
######################################################################
=pod
=item $parser->textblock( $text, $line_num, $pod_para )
L<Pod::Parser> callback.
=cut
######################################################################

sub textblock
{
Expand All @@ -520,11 +556,15 @@ sub textblock
push @{$self->{_out}}, $text;
}

=item $parser->interpolate( ... )
######################################################################
=pod
=item $parser->interpolate( $text, $line_num )
L<Pod::Parser> callback. Overloaded to also escape HTML entities.
=cut
######################################################################

sub interpolate
{
Expand All @@ -539,11 +579,15 @@ sub interpolate
return $text;
}

=item $parser->interior_sequence( ... )
######################################################################
=pod
=item $parser->interior_sequence( $seq_cmd, $seq_arg, $pod_seq )
L<Pod::Parser> callback.
=cut
######################################################################

sub interior_sequence
{
Expand Down Expand Up @@ -649,7 +693,8 @@ sub _p2w_fragment_id
my $generate = shift; # optional flag

$text =~ s/\s+\Z//s;
if( $text ){

if( $text ){
# a method or function?
return $1 if $text =~ /(\w+)\s*\(/;
return $1 if $text =~ /->\s*(\w+)\s*\(?/;
Expand All @@ -670,7 +715,7 @@ sub _p2w_fragment_id

return _fragment_id_readable($text, $generate);
} else {
return;
return "";
}
}

Expand Down

0 comments on commit b73512a

Please sign in to comment.