NAME

Perinci::To::Doc::Role::Section - Role for class that generates documentation with sections

VERSION

This document describes version 0.881 of Perinci::To::Doc::Role::Section (from Perl distribution Perinci-To-Doc), released on 2023-07-09.

DESCRIPTION

This is a role for classes that produce documentation with sections. This role provides a workflow for parsing and generating sections, regulating indentation, and a gen_doc() method.

To generate documentation, first you provide a list of section names in doc_sections. Then you run gen_doc(), which will call gen_doc_section_SECTION() method for each section consecutively, which is supposed to append lines of text to doc_lines. Finally all the added lines is concatenated together and returned by gen_doc().

ATTRIBUTES

doc_sections => ARRAY

Should be set to the names of available sections.

doc_lines => ARRAY

doc_indent_level => INT

doc_indent_str => STR (default ' ' (two spaces))

Character(s) used for indent.

METHODS

add_doc_section_before($name, $anchor)

add_doc_section_after($name, $anchor)

delete_doc_section($name)

inc_doc_indent([N])

dec_doc_indent([N])

gen_doc() => STR

Generate documentation.

The method will first initialize doc_lines to an empty array [] and doc_indent_level to 0.

It will then call before_gen_doc if the hook method exists, to allow class to do stuffs prior to document generation. Perinci::To::Text uses this, for example, to retrieve metadata from Riap server.

Then, as described in "DESCRIPTION", for each section listed in doc_sections it will call gen_doc_section_SECTION.

After that, it will call after_gen_doc if the hook method exists, to allow class to do stuffs after document generation.

Lastly, it returns concatenated doc_lines.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Perinci-To-Doc.

SOURCE

Source repository is at https://github.com/perlancar/perl-Perinci-To-Doc.

SEE ALSO

This role is used, among others, by: Perinci::To::* modules.

Perinci::To::Doc::Role::Section::AddTextLines which provides add_doc_lines to add text with optional text wrapping.

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

% prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2023, 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013 by perlancar <perlancar@cpan.org>.

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

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-To-Doc

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.