File Coverage

blib/lib/Perinci/To/Text.pm
Criterion Covered Total %
statement 12 70 17.1
branch 0 12 0.0
condition 0 25 0.0
subroutine 5 11 45.4
pod 0 6 0.0
total 17 124 13.7


line stmt bran cond sub pod time code
1             package Perinci::To::Text;
2              
3             our $DATE = '2021-02-21'; # DATE
4             our $VERSION = '0.875'; # VERSION
5              
6 1     1   152765 use 5.010001;
  1         15  
7 1     1   6 use Log::ger;
  1         2  
  1         11  
8 1     1   841 use Moo;
  1         12633  
  1         6  
9              
10 1     1   2196 use Locale::TextDomain::UTF8 'Perinci-To-Doc';
  1         23463  
  1         9  
11              
12             extends 'Perinci::To::PackageBase';
13             with 'Perinci::To::Doc::Role::Section::AddTextLines';
14              
15             sub BUILD {
16 1     1 0 55 my ($self, $args) = @_;
17             }
18              
19             sub gen_doc_section_summary {
20 0     0 0   my ($self) = @_;
21              
22             #my $meta = $self->meta;
23 0           my $dres = $self->{_doc_res};
24              
25 0           $self->SUPER::gen_doc_section_summary;
26              
27             my $name_summary = join(
28             "",
29             $dres->{name} // "",
30             ($dres->{name} && $dres->{summary} ? ' - ' : ''),
31 0 0 0       $dres->{summary} // ""
      0        
      0        
32             );
33              
34 0           $self->add_doc_lines(uc(__("Name")), "");
35              
36 0           $self->inc_doc_indent;
37 0           $self->add_doc_lines($name_summary);
38 0           $self->dec_doc_indent;
39             }
40              
41             sub gen_doc_section_version {
42 0     0 0   my ($self) = @_;
43              
44 0           my $meta = $self->meta;
45             #my $dres = $self->{_doc_res};
46              
47 0           $self->add_doc_lines("", uc(__("Version")), "");
48              
49 0           $self->inc_doc_indent;
50 0   0       $self->add_doc_lines($meta->{entity_v} // '?');
51 0           $self->dec_doc_indent;
52             }
53              
54             sub gen_doc_section_description {
55 0     0 0   my ($self) = @_;
56              
57 0           my $dres = $self->{_doc_res};
58              
59 0           $self->SUPER::gen_doc_section_description;
60 0 0         return unless $dres->{description};
61              
62 0           $self->add_doc_lines("", uc(__("Description")), "");
63              
64 0           $self->inc_doc_indent;
65 0           $self->add_doc_lines($dres->{description});
66 0           $self->dec_doc_indent;
67             }
68              
69             sub _gen_func_doc {
70 0     0     my $self = shift;
71 0           my $o = Perinci::Sub::To::Text->new(_pa=>$self->{_pa}, @_);
72 0           $o->gen_doc;
73 0           $o->doc_lines;
74             }
75              
76             sub gen_doc_section_functions {
77 0     0 0   require Perinci::Sub::To::Text;
78              
79 0           my ($self) = @_;
80              
81 0           my $dres = $self->{_doc_res};
82              
83 0           $self->add_doc_lines("", uc(__("Functions")), "");
84 0           $self->SUPER::gen_doc_section_functions;
85 0           my $i;
86 0           for my $furi (sort keys %{ $dres->{functions} }) {
  0            
87 0 0         $self->add_doc_lines('') if $i++;
88 0           my $meta = $dres->{function_metas}{$furi};
89 0 0 0       next if ($meta->{is_meth} || $meta->{is_class_meth}) && !($meta->{is_func} // 1);
      0        
      0        
90 0           for (@{ $dres->{functions}{$furi} }) {
  0            
91 0           chomp;
92 0           $self->add_doc_lines({wrap=>0}, $_);
93             }
94             }
95 0           $self->add_doc_lines('');
96             }
97              
98             sub gen_doc_section_methods {
99 0     0 0   require Perinci::Sub::To::Text;
100              
101 0           my ($self) = @_;
102              
103 0           my $dres = $self->{_doc_res};
104              
105 0           $self->add_doc_lines("", uc(__("Methods")), "");
106 0           $self->SUPER::gen_doc_section_methods;
107 0           my $i;
108 0           for my $furi (sort keys %{ $dres->{functions} }) {
  0            
109 0 0         $self->add_doc_lines('') if $i++;
110 0           my $meta = $dres->{function_metas}{$furi};
111 0 0 0       next unless ($meta->{is_meth} || $meta->{is_class_meth}) && !($meta->{is_func} // 1);
      0        
      0        
112 0           for (@{ $dres->{functions}{$furi} }) {
  0            
113 0           chomp;
114 0           $self->add_doc_lines({wrap=>0}, $_);
115             }
116             }
117 0           $self->add_doc_lines('');
118             }
119              
120             1;
121             # ABSTRACT: Generate text documentation for a package from Rinci metadata
122              
123             __END__
124              
125             =pod
126              
127             =encoding UTF-8
128              
129             =head1 NAME
130              
131             Perinci::To::Text - Generate text documentation for a package from Rinci metadata
132              
133             =head1 VERSION
134              
135             This document describes version 0.875 of Perinci::To::Text (from Perl distribution Perinci-To-Doc), released on 2021-02-21.
136              
137             =head1 SYNOPSIS
138              
139             use Perinci::To::POD;
140             my $doc = Perinci::To::Text->new(
141             name=>'Foo::Bar', meta => {...}, child_metas=>{...});
142             say $doc->gen_doc;
143              
144             You can also try the L<peri-doc> script with the C<--format text> option:
145              
146             % peri-doc --format text /Some/Module/
147              
148             To generate a usage-like help message for a single function, you can try the
149             L<peri-func-usage> from the L<Perinci::CmdLine::Classic> distribution.
150              
151             =for Pod::Coverage .+
152              
153             =head1 HOMEPAGE
154              
155             Please visit the project's homepage at L<https://metacpan.org/release/Perinci-To-Doc>.
156              
157             =head1 SOURCE
158              
159             Source repository is at L<https://github.com/perlancar/perl-Perinci-To-Doc>.
160              
161             =head1 BUGS
162              
163             Please report any bugs or feature requests on the bugtracker website L<https://github.com/perlancar/perl-Perinci-To-Doc/issues>
164              
165             When submitting a bug or request, please include a test-file or a
166             patch to an existing test-file that illustrates the bug or desired
167             feature.
168              
169             =head1 AUTHOR
170              
171             perlancar <perlancar@cpan.org>
172              
173             =head1 COPYRIGHT AND LICENSE
174              
175             This software is copyright (c) 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013 by perlancar@cpan.org.
176              
177             This is free software; you can redistribute it and/or modify it under
178             the same terms as the Perl 5 programming language system itself.
179              
180             =cut