Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-20 02:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found