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