Home > Net >  How can I check if a function has POD (perl in-file documentation)?
How can I check if a function has POD (perl in-file documentation)?

Time:08-20

Is there any library that can tell me if a specific function has POD? I want to add that into our build system.

As in, the convention as established in the docs on POD,

=item stuff()

This function does stuff.

=cut

sub stuff {
  ...
}

I want to write something like this

my @functions = get_functions_with_PPI($file);

foreach my $func (@functions) {
  unless ( file_has_POD_for_func($file,$func) ) {
    say "The function $func is undocumented!";
  }
}

I need something that does file_has_POD_for_func as documented above.

CodePudding user response:

Pod::Coverage

Pod::Coverage does what you want. Devel::Cover uses it internally.

CodePudding user response:

Instead of using PPI, use something like Pod::Simple or Pod::Parser to parse the source file.

Note that you will have to rely on the author following conventions of mentioning the functions in an =item or (more commonly) =head2 tag.

You may want to look at the source for something like Pod::Coverage that checks if all functions in a module are mentiomned in POD, assuming that isn't something you are trying to do already.

  • Related