| 64 | | if ( defined $pdl_help && exists $pdl_help->{$topic} ) { |
| 65 | | $html = ''; |
| 66 | | my $help = $pdl_help->{$topic}; |
| 67 | | my %SECTION_NAME = ( |
| 68 | | Module => 'Module', |
| 69 | | Ref => 'Reference', |
| 70 | | Sig => 'Signature', |
| 71 | | Bad => 'Bad values', |
| 72 | | Usage => 'Usage', |
| 73 | | Example => 'Example', |
| 74 | | ); |
| 75 | | foreach my $section (qw(Module Ref Sig Bad Usage Example)) { |
| 76 | | if ( defined $help->{$section} ) { |
| 77 | | my $help = $help->{$section}; |
| 78 | | my $name = $SECTION_NAME{$section}; |
| 79 | | if ( $section eq 'Example' |
| 80 | | or $section eq 'Sig' |
| 81 | | or $section eq 'Usage' ) |
| 82 | | { |
| 83 | | $html .= "<p><b>$name</b><pre>" . $help . "</pre></p>"; |
| 84 | | } elsif ( $section eq 'Module' ) { |
| 85 | | $html .= qq{<p><b><a href="perldoc:$help">$help</a></b></p>}; |
| 86 | | } else { |
| 87 | | $html .= "<p><b>$name</b><br>" . $help . "</p>"; |
| 88 | | } |
| 89 | | } |
| | 57 | if ( defined $pdl_help && exists $pdl_help->gethash->{$topic} ) { |
| | 58 | require Padre::Pod2HTML; |
| | 59 | |
| | 60 | # We have two possibilities: the $topic can either be a module, or it |
| | 61 | # can be a function. If the latter, we extract its pod from the database. |
| | 62 | # If the former, just pull the pod from the file. We distinguish between |
| | 63 | # them by noting that functions have a Module key, whereas modules |
| | 64 | # (ironically) don't. |
| | 65 | if (exists $pdl_help->gethash->{$topic}->{Module}) { |
| | 66 | # Get the pod docs from the docs database: |
| | 67 | my $pod_handler = StrHandle->new; # defined in PDL::Doc |
| | 68 | $pdl_help->funcdocs($topic, $pod_handler); |
| | 69 | |
| | 70 | # Convert them to HTML |
| | 71 | $html = Padre::Pod2HTML->pod2html($pod_handler->text); |
| | 72 | |
| | 73 | # Replace the filename in the "docs from" section with the module name: |
| | 74 | my $module_name = $pdl_help->gethash->{$topic}{Module}; |
| | 75 | $html =~ s{Docs from .*\.pm} |
| | 76 | {Docs from <a href="perldoc:$module_name">$module_name<\/a>}; |