3

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.

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
  • 2
    It looks like you are trying to replicate exactly what Pod::Coverage does. And if you want to incorporate it into your test suite, then you can use Test::Pod::Coverage. – Andy Lester Aug 19 '22 at 21:45

2 Answers2

4

Pod::Coverage

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

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
2

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 mentioned in POD, assuming that isn't something you are trying to do already.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Rob
  • 781
  • 5
  • 19