http://qs321.pair.com?node_id=11115528

nysus has asked for the wisdom of the Perl Monks concerning the following question:

perldoc -f works for built-in Perl functions. I'm wondering if there is a tool out there for pulling up a pod entry for a function in my own module. Thanks.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

  • Comment on Tool for pulling up documentation for individual functions in a module?
  • Download Code

Replies are listed 'Best First'.
Re: Tool for pulling up documentation for individual functions in a module?
by haukex (Archbishop) on Apr 14, 2020 at 17:30 UTC
    perldoc -f works for built-in Perl functions. I'm wondering if there is a tool out there for pulling up a pod entry for a function in my own module. Thanks.

    perlfunc is treated specially by the tools, it's not a general-purpose solution at work there. Although there is Pod::Select, that's deprecated in the core now, and it seems to me that Pod-Simple doesn't have a direct replacement. A couple of possible solutions are: I haven't tried them, but on CPAN there's Pod::Simple::Select and Pod::Section (sadly, both modules don't appear to have a decent test suite). Lower-level would be to have a look at how the select method in Pod::Usage works (that module could also be used in a hacky solution by redirecting its output), or if you want to write something custom, I've used Pod::Simple::SimpleTree (example).

Re: Tool for pulling up documentation for individual functions in a module?
by choroba (Cardinal) on Apr 14, 2020 at 17:32 UTC
    I use etags (or rather, my own version of it). In Emacs, when I press M-. on a function/package name, it takes me directly to its declaration. Changing it to show the documentation instead should be easy enough.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      Haven't used yet but this reminded me that there's a perl lsp server (Perl::LanguageServer). Together with lsp-mode that might be fruitful to look at (not that etags/ctags/GNU global aren't also useful).

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.