Smart Docs in PerlySense does someting that sounds very similar to what you want.

Pressing C-o C-d on a method name will try to find it and display the sub/method POD in the echo area (screen shot).

The PerlySense command line script can only output Emacs elisp and Vim dictionary data structures at the moment, but it should be trivial to just get the POD text.

Actually, here's a minimal script to do that. Install Devel::PerlySense and save this into psdoc.pl:

#!/usr/bin/perl -w use strict; use warnings; use Devel::PerlySense; { my ($module_name, $sub_name) = @ARGV; $module_name && $sub_name or die("Syntax: $0 MODULE SUB\n"); my $ps = Devel::PerlySense->new(); my $class = $ps->classByName(name => $module_name, dirOrigin => ". +") or die("Could not find module ($module_name)\n"); my $location = $class->oLocationMethodDoc(method => $sub_name) or die("Could not find sub ($sub_name)\n"); my $pod_text = $location->rhProperty->{text} || "No docs"; print("$pod_text\n"); } __END__

E.g. call:

psdoc.pl HTTP::Response base DESCRIPTION $r->base Returns the base URI for this response. The return value will +be a reference to a URI object. The base URI is obtained from one the following sources (in pr +iority order):

(actually, that one triggers a bug where =item pod isn't treated properly, but I'll fix that :)

Obviously it won't work for everything since not all module POD are structured in a way that makes it possible to find it. but if the sub/method name is mentioned in a =head or =item line it should work most of the time.

For your own code it could work flawlessly, since you can be diciplined and document things properly (especially if you can see the obvious benefit). Here's an example:

psdoc.pl Devel::CoverX::Covered::Db test_files_covering METHODS test_files_covering($source_file_name, [$sub]) : @test_file_names Return list of test files that cover any line in $source_file_name +. Or if $sub is passed, limit to test files covering that sub.

To be fair, I don't use this hugely often myself. For a project code base I find that I usually need to go to the method anyway in order to make sure I know enough to call it. And for CPAN modules it's usually beneficial to read the whole thing and to make sure I'm not missing something.

But I hope you'll find it useful.

/J


In reply to Re: POD, come let me see thee, I have thee not, but still I clutch thee by jplindstrom
in thread POD, come let me see thee, I have thee not, but still I clutch thee by Bloodnok

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.