Indexing MooseX::Declare modules

As a PAUSE admin, I ran into a new problem today. The URI::Dispatch module did not index because it has no package statements and has no provides in META.yml.

This leads me to a couple of questions, for which I invite you to answer:

  • Just how hard should the PAUSE indexer work to discover namespaces when you work hard to hide them? Remember, at the moment it's only MooseX::Declare, but it might be many other modules later.
  • What are other MooseX::Declare people doing to have their stuff indexed?

I'm also thinking about this for my BackPAN indexing bits, which uses my module Module::Extract::Namespaces. That's a PPI-based module, which I guess I now have to mutate to understand Moose. I haven't thought too much about that, so I'm not sure how I'm going to do that.

8 Comments

I think that your PAUSE issue is the author's fault. I think the correct answer is to include provides in META.(yml|json).

As for the second question, please don't conflate Moose with MooseX::Declare. I use Moose in DBIx::Class::DeploymentHandler and never had an issue with indexing on PAUSE; modules using Moose are just vanilla Perl with a line that says: "use Moose;"

MooseX::Declare uses Devel::Declare, which hooks into Perl's tokenizer and *that*'s what's causing your issues.

There are things like Dist::Zilla::Plugin::MetaProvides and Module::Install::ProvidesClass that allow for things like this.

The simple solution right now would be to also look for "class XXXXX {}" statements when looking for "package XXXXX" fails.

Sure, if someone comes up with another syntax, it would still be an issue, but at least this will work for now.

It's already pointed out, but Module::Install::ProvidesClass is designed to solve this by scanning the class keywords in MooseX-Declare based code using Class::Discover and put them in META.yml:
http://search.cpan.org/~ash/Module-Install-ProvidesClass-1.000000/lib/Module/Install/ProvidesClass.pm

Nilson: Please don't get this the wrong way. But the problem isn't that the CPAN admins are entirely not capable of extending the indexer. It's just that there's at best a handful of us and we're not exactly the most idle people in the world. That means we can't possibly try to keep the indexer up to date with all things happening on CPAN. That in turn means that either the authors of the syntax extension or the authors of the CPAN distributions (or a third party) need to supply patches to make it work for everybody. I'm sure Andreas wouldn't turn down a patch to *properly* index MooseX::Declare classes. PAUSE is open source.
Sad as it may be, CPAN admins don't scale. :)

This appears to be somewhat of a hot topic here including your recent posts (and their comments) plus this one by David Cantrell: http://blogs.perl.org/users/david_cantrell/2011/07/cpxxxan-update.html

My uneducated opinion is that the Indexer shouldn't have to work that hard. The onus should be on a module author to make your dist index-able/parse-able/sane. The CPAN doesn't need your dist (as is suggested in various documents), and you don't need to do weird stuff to make the indexer's job (and that of the indexer's maintainers) harder.

If you have a valid reason for making your packages not easily discoverable, then the 'provides' key is a solution for you. If you have trouble filling in your 'provides' key because doing it manually is problematic and your dist doesn't automatically index with the current tools, then you understand the problem. That should be an inspiration to either make your dist easier to index or to improve the indexing tools.

My previous comment is probably more influenced by the goofiness of common::sense (mentioned in David Cantrell's post) than by MooseX::Declare (of which I am not familiar)...

I am not against new syntaxes or new ways of doing things, but if it were my dist I'd fill in the META 'provides' to make sure it got indexed properly, knowing that what I was doing was unusual and it was my responsibility to package my dist correctly.

For the record, I *do* fill in META provides (automatically using Dist::Zilla::Plugin::MetaProvides).

Is there a reason the META file (and 'provides' section) is optional (besides backward compatibility)? If it had been a requirement from the beginning the indexer wouldn't have needed to do so much in the first place. To me it seems like the dist builder is the appropriate place for it.

If CPAN::Meta::Spec was the wave of the future (and became more of a requirement), then the PAUSE Indexer would only be required for backward compatibility (old dists from before the Spec) and therefore wouldn't need to adapt to whatever may come up in the future (which should use the Spec). Otherwise, what was the Spec for?

Leave a comment

About brian d foy

user-pic I'm the author of Mastering Perl, and the co-author of Learning Perl (6th Edition), Intermediate Perl, Programming Perl (4th Edition) and Effective Perl Programming (2nd Edition).