Skip to content

Commit

Permalink
Item14237: PERLDOC macro now skips out module name if referencing in …
Browse files Browse the repository at this point in the history
…the same module which is currently processed by INCLUDE::doc handler

The handler now sets DOC_MODULE session preference
  • Loading branch information
vrurg committed Oct 20, 2017
1 parent e2b5ffe commit f06d354
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions core/lib/Foswiki/IncludeHandlers/doc.pm
Expand Up @@ -54,6 +54,8 @@ sub INCLUDE {
$classLoadError = $e->stringify;
};

$app->prefs->setSessionPreferences( "DOC_MODULE", $class );

my %publicPackages = map { $_ => 1 } _loadPublishedAPI($app);
my $visibility = exists $publicPackages{$class} ? 'public' : 'internal';
_setNavigation( $app, $class, $publicOnly, \%publicPackages );
Expand Down
7 changes: 5 additions & 2 deletions core/lib/Foswiki/Macros/PERLDOC.pm
Expand Up @@ -19,15 +19,18 @@ sub expand {

my $result = "";

my $module = $params->{_DEFAULT} || 'Foswiki';
my $prefModule = $this->app->prefs->getPreference('DOC_MODULE');
my $module = $params->{_DEFAULT} || $prefModule || 'Foswiki';
my $noModuleInText = $module eq $prefModule;
my ( $anchor, $type, $linkText ) = ( "", "", $module );

TYPE: foreach $type (qw<method attr attribute>) {
if ( defined $params->{$type} ) {
$anchor =
Foswiki::IncludeHandlers::doc::_makeAnchor( $this->app,
$type => $params->{$type} );
$linkText = $module . "::" . $params->{$type};
$linkText =
( $noModuleInText ? "" : "${module}::" ) . $params->{$type};
$linkText .= "()" if ( $type eq 'method' );
$linkText = "$linkText";
last TYPE;
Expand Down

0 comments on commit f06d354

Please sign in to comment.