I would like to be able to see the method / function documentation when using it inside a REPL or debuger.
Is there any module that will allow you to see the documentation of the function when using REPL or debuger ?.
Obviously, if this module exists, it will ask you to have your POD and syntax-structured code for document extraction. This is not a problem, because I have all my code, and I can adapt to what is needed. Currently I have all my methods with previous PODs =head2 method_nameand typical strings for name, usage, example, arguments, return, exceptions, etc.
A typical example: when you are in a debugger (or REPL), and you want to use a function, and you do not remember the order of the arguments or their types, the type of the returned item, or want to get a hint for use.
I would like to have something like get_pod ($ moudle_bar, $ method_foo) or even better put get_pod in the base module and say $bar->get_pod('foo'). I know that this is not trivial and has many angular cases. It is for this reason that I ask about the POD method extractor module.
I want to show the result inside REPL or debuger, so any pointer to the attached html-pod in the browser is not convenient for me.
Maybe there is something much simpler, and I'm confused.
My first brute force and expensive approach:
> $self = new MyModule
> m $self
>
> $cmd = 'perldoc -t ' . ref($self)
> x qx{$cmd}=~/(_connect_db.*?)\n\n/msg
0 '_connect_db
Title: _connect_db
Usage:
Function: create a database conection and return the handler
Example : $dbh = $self->_connect_db($user, $pass, $db_name) # host is FPrefect by default
Returns : [0] DBI $dbh object
Args :
[0] $user,
[1] $pass,
[2] $db_name,
[3] $host,
[4] $db_brand # mysql, sqlite
[5] $mode = (ro, rw) # not used now. in the future it would use this for read the user and password'
, , , POD, .*?)\n\n , POD.
- ?
UPDATE:
snoopy, Pod:: Coverage, , Pod:: Coverage:: Extractor ( Pod:: Coverage) command, . , .
sub command {
my $self = shift;
my ( $command, $text, $line_num ) = @_;
if ( $command eq 'item' || $command =~ /^head(?:2|3|4)/ ) {
my @pods = ( $text =~ /\s*([^\s\|,\/]+)/g );
$self->{recent} = [];
foreach my $pod (@pods) {
print "Considering: '$pod'\n" if debug;
$pod =~ /-E<\s*gt\s*>(.*)/ and $pod = $1;
$pod =~ /->(.*)/ and $pod = $1;
$pod =~ /\w+(?:::\w+)*::(\w+)/ and $pod = $1;
$pod =~ s/[A-Z]<//g;
$pod =~ s/>//g;
$pod =~ /(\w+)\s*[;\(]/ and $pod = $1;
print "Adding: '$pod'\n" if debug;
push @{ $self->{ $self->{nonwhitespace}
? "recent"
: "identifiers" } }, $pod;
}
}
2
, , pdoc. script html API-, Ensembl BioPerl. , -, .