App::DocKnot::Generate(3pm)

App::DocKnot::Generate3pm

Generate documentation from package metadata

Usage

    use App::DocKnot::Generate;
    my $docknot
      = App::DocKnot::Generate->new({ metadata => 'docs/docknot.yaml' });
    my $readme = $docknot->generate('readme');
    my $index = $docknot->generate('thread');
    $docknot->generate_output('readme');
    $docknot->generate_output('thread', 'www/index.th')

Requirements

Perl 5.24 or later and the modules File::BaseDir, File::ShareDir, Kwalify, Path::Tiny, Template (part of Template Toolkit), and YAML::XS, all of which are available from CPAN.

Overview

This component of DocKnot provides a system for generating consistent human-readable software package documentation from metadata files, primarily JSON and files containing documentation snippets. It takes as input a directory of metadata and a set of templates and generates a documentation file from the metadata given the template name.

The path to the metadata directory for a package is given as an explicit argument to the App::DocKnot::Generate constructor. All other data (currently templates and license information) is loaded via File::BaseDir and therefore uses XDG paths by default. This means that templates and other global configuration are found by searching the following paths in order:

1.

$HOME/.config/docknot

2.

$XDG_CONFIG_DIRS/docknot (/etc/xdg/docknot by default)

3.

Files included in the package.

Default templates and license files are included with the App::DocKnot module and are used unless more specific configuration files exist.

Class methods

new(ARGS)

Create a new App::DocKnot::Generate object. This should be used for all subsequent actions. ARGS should be a hash reference with one or more of the following keys:

metadata

The path to the directory containing metadata for a package. Default: docs/docknot.yaml relative to the current directory.

width

The wrap width to use when generating documentation. Default: 74.

Instance methods

generate(TEMPLATE)

Load the metadata from the path given in the constructor and generate the documentation file defined by TEMPLATE, which is the name of a template. The template itself will be loaded from the App::DocKnot configuration path as described in DESCRIPTION. Returns the generated documentation file as a string.

generate_all()

Generate all of the documentation files for a package. This is currently defined as the "readme" and "readme-md" templates. The output will be written to the default output locations, as described under generate_output().

generate_output(TEMPLATE [, OUTPUT])

The same as generate() except that rather than returning the generated documentation file as a string, it will be written to the file named by OUTPUT. If that argument isn't given, a default based on the TEMPLATE argument is chosen as follows:

    readme     ->  README
    readme-md  ->  README.md

If TEMPLATE isn't one of the templates listed above, the OUTPUT argument is required.

Releases

3 releases since Debian 11 (Bullseye); the text changed 2 times.

  1. 11
  2. 12
  3. 13

Author

Russ Allbery <[email protected]>

From docknot 8.0.1-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.