Christopher J. Madsen > Pod-PluginCatalog-0.01 > Pod::PluginCatalog

Download:
Pod-PluginCatalog-0.01.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Pod::PluginCatalog - Format a catalog of plugin modules

VERSION ^

This document describes version 0.01 of Pod::PluginCatalog, released July 28, 2012 as part of Pod-PluginCatalog version 0.01.

SYNOPSIS ^

  use Pod::PluginCatalog;

  my $catalog = Pod::PluginCatalog->new(
    namespace_rewriter => sub { 'My::Plugin::Namespace::' . shift },
    pod_formatter => sub {
      my $parser = Pod::Simple::XHTML->new;
      $parser->output_string(\my $html);
      $parser->html_header('');
      $parser->html_footer('');
      $parser->perldoc_url_prefix("https://metacpan.org/module/");
      $parser->parse_string_document( shift );
      $html;
    },
  );

  $catalog->add_file('catalog.pod');

  $catalog->generate_tag_pages($header, $entry, $footer);
  $catalog->generate_index_page($header, $entry, $footer);

DESCRIPTION ^

Warning: This is still early code, not yet in production. The API might change.

This module aids in formatting a tag-based catalog of plugins. It was written to create the catalog at http://dzil.org/plugins/ but should also be useful for similar catalogs. (That catalog is not yet live as of this writing; a preview is at http://dzil.cjmweb.net/plugins/ and the code that generates it at https://github.com/madsen/dzil.org/tree/plugin-catalog.)

The catalog begins with one or more POD files defining the available plugins and the tags used to categorize them. You load each file into the catalog with the add_file method, and then call the generate_tag_pages and generate_index_page methods to produce a formatted page for each tag and an index page listing all the tags.

EXTENDED POD SYNTAX ^

This module defines three non-standard POD command paragraphs used to create the catalog:

=author

  =author CPANID

This sets the author for all following plugins (until the next =author). If CPANID is omitted, it resets the author to the default (which is no listed author, represented by undef).

=plugin

  =plugin PluginName tagname tagname...

This paragraph defines a plugin and associates it with the specifed tags. Neither PluginName nor the tag names may contain whitespace, because the paragraph content is simply split(' ', ...). The first element is the name, and the rest are the tags. (This means that a single newline is equivalent to a space.)

The following paragraphs (if any) form the description of the plugin. The description may include ordinary paragraphs, verbatim (indented) paragraphs, and the commands =head3, =head4, =over, =item, and =back.

=tag

  =tag tagname

This defines a tag. The following paragraphs (if any) form the description of the tag (using the same rules as a plugin's description).

You'll get a warning if any plugin uses a tag that was not defined by a =tag command, or if any tag is defined but never used by any plugin. (The warnings are generated only when you output the results; the order =tag and =plugin occur doesn't matter.)

ATTRIBUTES ^

delimiters

This is an arrayref of two strings: the opening and closing delimiters for Text::Template. (default {{ }})

file_extension

This suffix is appended to the tag name to form the filename for each generated page. (default .html)

namespace_rewriter

This is a coderef to a function that takes one argument (a plugin name) and returns the corresponding module name. (required)

perlio_layers

This string contains the PerlIO layers to be used when opening files for output. (default :utf8)

pod_formatter

This is a coderef to a function that takes one argument (a string containing POD) and returns the string formatted as it should appear in the output. That can be HTML or any other format. The string is guaranteed to start with a POD command paragraph. (required)

METHODS ^

add_document

  $catalog->add_document($name => $doc);

This adds a Pod::Elemental::Document to the catalog. The $name is used for error messages. May be called multiple times.

add_file

  $catalog->add_file($filename);

This is just a wrapper around add_document to read a file on disk.

generate_index_page

  $catalog->generate_index_page($header, $entry, $footer);

This generates an index file listing each tag in the catalog. The filename will be index with the "file_extension" appended.

$header, $entry, and $footer are strings to be passed to Text::Template using the "delimiters".

The $header and $footer templates can refer to the following variables (so that you can use the same header & footer for generate_tag_pages if you want to):

  $tag              Will be undef
  $tag_description  Will be undef

The $entry template is printed once for each tag. In addition to the previous variables, it may also use these:

  $tag          The tag being listed (no longer undef)
  $description  The description of that tag

generate_tag_pages

  $catalog->generate_tag_pages($header, $entry, $footer);

This generates a file for each tag in the catalog. It generates the filenames by appending the "file_extension" to each tag name.

$header, $entry, and $footer are strings to be passed to Text::Template using the "delimiters".

The $header and $footer templates can refer to the following variables:

  $tag              The name of the tag being processed
  $tag_description  The description of that tag (may be undef)

The $entry template is printed once for each plugin. In addition to the previous variables, it may also use these:

  $author       The author of this plugin (may be undef)
  $name         The name of this plugin
  $module       The module name of the plugin
  $description  The description of the plugin
  @other_tags   The tags for this plugin (not including $tag)

CONFIGURATION AND ENVIRONMENT ^

Pod::PluginCatalog requires no configuration files or environment variables.

INCOMPATIBILITIES ^

None reported.

BUGS AND LIMITATIONS ^

No bugs have been reported.

AUTHOR ^

Christopher J. Madsen <perl AT cjmweb.net>

Please report any bugs or feature requests to <bug-Pod-PluginCatalog AT rt.cpan.org> or through the web interface at http://rt.cpan.org/Public/Bug/Report.html?Queue=Pod-PluginCatalog.

You can follow or contribute to Pod-PluginCatalog's development at http://github.com/madsen/pod-plugincatalog.

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2012 by Christopher J. Madsen.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTY ^

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

syntax highlighting: