Give your module a good SEE ALSO section
The SEE ALSO section in your module's pod is where you direct the reader to other things of interest. In this post I'll briefly outline what constitutes a good SEE ALSO, and why it benefits you to create one.
My thoughts on this topic have evolved over time, and in writing this I've realised that a lot of my modules could do with a brush up. I'll be releasing those on CPAN Day, of course :-)
There are a number of different things you can present in your SEE ALSO:
- Other modules that provide similar functionality (aka competitors).
- Other modules that might be used together with your module.
- Other modules that are part of the same distribution.
- Sources of related information, such as wikipedia pages, published papers, etc
Personally, I think the following things don't belong here:
- Listing the modules that your module uses (ie dependencies).
In MetaCPAN they're already listed in a right-hand sidebar, so you shouldn't duplicate them.
One exception is where part of your module's interface is provided by the dependency.
- A lot of older modules list(ed) "perl(1)" and similar.
Golden rule: make things links
When listing other modules, make them links:
=head1 SEE ALSO
L<Acme::CPANAuthors::YakShavers>
MetaCPAN, search.cpan.org and other sites will make these hyperlinks.
When giving a URL, you can give link text:
See the L<wikipedia page|http://en.wikipedia.org/....>
for a description of the algorithm.
You can read more about the L<> formatting code in the perlpod documentation.
Listing your competitors
First you need to find the other modules that provide similar functionality. This isn't always easy, but the distribution search on search.cpan.org is a good place to start. I also grep 02packages.details.txt, but realise that's not for everyone.
Once you've got a first list of modules, look at their SEE ALSO sections, to see if there are other modules you've missed. Usually this comes down to namespaces you hadn't considered, and searching those namespaces can turn up more modules.
As a start, you can just give a list of links (eg as in Lingua::EN::Numbers):
=head1 SEE ALSO
L<Foo::Bar>, L<Foo::Baz>, L<Delicious::Marmite>.
But it's even more helpful for CPAN users if you give a small summary of each module, focussing on how it differs from yours.
L<Foo::Bar::XS> provides the same interface,
but is much faster (because it's written in C).
The downside is that you need a compiler.
As an example, look at the SEE ALSO for Text::Levenshtein, which I added when I adopted the module.
If there are a lot of modules, then you might give a summary of the main contenders, and then just list the others (as links, of course!).
So, why bother doing all this?
- It helps people who are looking for something on CPAN. Your module might be awesome, but another module might provide the specific function someone is after, or maybe you have too many dependencies for them, or ...
- It aids discoverability. Listing other modules makes it more likely that your module will be found. For example, if you search for Path::ScanINC on MetaCPAN, you'll see my module Module::Path listed in the results. That's because I list Path::ScanINC in the SEE ALSO section.
- Looking at your competitors can improve the way you think about / code / document your module, and give you ideas for new features.
In my dream world, whenever someone has an idea for a module, they start by writing the SEE ALSO section. By the time they've done that, they either decide not to bother, or they have a better concept of what ecological niche they're going to occupy. Bwahahaha!
Apart from the fact of you flooding my TODO list ;-) I can only say it is good advice.
I myself do however have the practice of making a DEPENDENCIES section in addition to SEE ALSO so you can list dependencies as a part of the documentation, this is also the recommendation from the Perl::Critic policy (https://metacpan.org/pod/Perl::Critic::Policy::Documentation::RequirePodSections) and PBP (if I remember correctly). MetaCPAN is not necessarily the only place where documentation is presented.
Looking forward to CPAN day, take care,
jonasbn
jonasbn: happy I'm keeping your todo list primed, as long as you're going to address that on CPAN Day? :-)
You're right, it is in PBP, in the section on Documentation Boilerplates - I'd forgotten about that. The specific bit about the DEPENDENCIES section is on page 135. Surprisingly there doesn't seem to be a Pod::Weaver / Dist::Zilla plugin to generate this.
PBP doesn't mention it, but you might also want to draw a distinction between what deps are needed to install / test, and which ones are used by the dist vs by the module. For single-module dists that's straightforward, but not for more complicated dists.
Not sure what I think about this section. It's useful for someone looking at your module, but you need to present the right information in an easy-to-grok way. And it needs to be maintained. And it duplicates information presented by MetaCPAN for example, which is derived from metadata. Hmm.
Now that we have META.yml/META.json the DEPENDENCIES section is quite irrelevant as it is not as powerful as the raw data. Sites like MetaCPAN can process META files to render them for humans, even for modules that don't have the DEPENDENCIES documentation.
I rarely write a DEPENDENCIES section, but I did for Type::Tiny, and it's more than just a duplication of the right-hand column on metacpan.
Wouldn't it be even better to have an entry in META.json listing the related modules?
Gabor: it would be a useful addition to have some information in the dist metadata. But where the SEE ALSO might link to various types of things, the metadata would have to be better structured.
For example, we could have an x_similar_to, or something like this, which is for listing modules which provide at least some of the same functionality. This would enable a [more like this] function in MetaCPAN, for example.
Then we could also have x_superseded_by, x_deprecated (discussed elsewhere as well, I know)
Would be even better if it had some more ontological juice, but I don't think enough dists would get that to make it worth while.
We're drifting into the tagging discussion, and things like Yanick's suggestion: http://techblog.babyl.ca/entry/metacpan-recommendations
Something to remember for all of Neil's excellent posts in this series - if you don't have any distributions of your own that you can patch, you can patch other people's distributions!
Bit of wishful thinking there @ether? Got some nasty bugs you're hoping someone else will fix for you? ;-)