NAME

Pod::Autopod - Generates pod documentation by analysing perl modules.

SYNOPSIS

new Pod::Autopod(readfile=>'Foo.pm', writefile=>'Foo2.pm');

# reading Foo.pm and writing Foo2.pm but with pod


my $ap = new Pod::Autopod(readfile=>'Foo.pm');
print $ap->getPod();

# reading and Foo.pm and prints the generated pod. 


my $ap = new Pod::Autopod();
$ap->setPerlCode($mycode);
print $ap->getPod();
$ap->writeFile('out.pod');

# asumes perl code in $mycoce and prints out the pod.
# also writes to the file out.pod

DESCRIPTION

This Module is designed to generate pod documentation of a perl class by analysing its code. The idea is to have something similar like javadoc. So it uses also comments written directly obove the method definitions. It is designed to asumes a pm file which represents a class.

Of course it can not understand every kind of syntax, parameters, etc. But the plan is to improve this library in the future to understand more and more automatically.

Please note, there is also an "autopod" command line util in this package.

REQUIRES

Pod::Abstract::BuildNode

Pod::Abstract

FileHandle

HOWTO

To add a documentation about a method, write it with a classical remark char "#" before the sub{} definition:

# This method is doing foo.
#
#  print $this->foo();
#
# 
# It is not doing bar, only foo.
sub foo{
  ...
}

A gap before sub{} is allowed.

In further versions of autopod, here new features will appear.

To define parameters and return values you can use a boundle of keywords. So far parameters and return values can not realy be autodetected, so manual way is necessary, but it is designed to type it rapidly.

sub foo{ # void ($text)
 ...
}

The example above produces the following method description:

$this->foo($text);

The object "$this" is the default and automatially used when a constructor was found ("new"). You can change this by the parameter "selfstring" in the autoperl constructor.

The example looks simple, but the engine does more than you think. Please have a look here:

sub foo{ # void (scalar text)
 ...
}

That procudes the same output! It means the dollar sign of the first example is a symbol which means "scalar".

sub foo{ # ($)
 ...
}

Produces:

$this->foo($scalar);

As you see, that was the quickest way to write the definition. The keywork "void" is default.

The following keywords or characters are allowed:

array       @
arrayref   \@
hash        %
hashref    \%
method      &
scalar      $
scalarref  \$
void       only as return value

Now a more complex example:

sub foo{# $state ($firstname,$lastname,\%persondata)
...
}

produces:

my $state = $this->foo($firstname, $lastname, \%persondata);

or write it in java style:

sub foo{# scalar state (scalar firstname,scalar lastname,hashref persondata)
...
}

Multiple return values may be displayed as following:

sub foo{# $a,$b ($text)
...
}

produces:

my ($a, $b) = $this->foo($text);

If you want to use key values pairs as in a hash, you may describe it like:

sub foo{# void (firstname=>$scalar,lastname=>scalar)
...
}

The second "scalar" above is without a "$", that is no mistake, both works.

There is also a way to expain that a value A OR B is expected. See here:

sub foo{# $lista|\$refb (\@list|$text,$flag)
...
}

procudes:

my $lista | \$refb = $this->foo(\@list | $text, $flag);

Of course, that is not an official perl syntax with the or "|", but it shows you that is expected.

In the First Part obove all method descriptions, you can add general informations, which are per default displayed under the head item "DESCRIPTION". But also own items can be used by underlining a text with "=" chars like:

# HOWTO
# =====
# Read here howto do it.   

Some of these title keywords are allways places in a special order, which you can not change. For example LICENSE is allways near the end.

METHODS

new

my $object = $this->new($filename => $scalar, alsohiddenmethods => $scalar, selfstring => $scalar);

ConstructorThe keyvalues are not mandatory.selfstring may hold something like '$self' as alternative to '$this', which is default.alsohiddenmethods gets a boolean flag to show also methods which starts with "_".

buildPod

$this->buildPod();

Builds the pod. Called automatically when imporing a perl code.

getPerlCode

my $text = $this->getPerlCode();

Returns perl code which was set before.

getPod

my $text = $this->getPod();

Returns the pod formated text.s

scanArray

$this->scanArray();

This class may scan the perl code.But it is called automatically when importing a perl code.

setPerlCode

$this->setPerlCode($text | \@array);

Expects Perl code as arrayrefor text (scalar).When used, it automatically runs scanArray().

writeFile

$this->writeFile($filename);

writes a pod fileIf the file has a pm extension, it writes the perl code and the podIf the file has a pod extension or any, it only writes the pod.

AUTHOR

Andreas Hernitscheck ahernit(AT)cpan.org

LICENSE

You can redistribute it and/or modify it under the conditions of LGPL.