bin/markpod

filter: Statementstmt 79.0% 34 / 43 Branchbran 36.6% 11 / 30 Conditioncond 25.0% 3 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 54.6% 53 / 97 CC 1 SCAR 0.0
CC
1
Cov
56%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Markdown/Pod/Embed/Constant.pm ↑ Summary
1 #!/usr/bin/env perl
2  
3 #
4 # This file is part of Markdown::Pod::Embed.
5 #
6 # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>.
7 #
8 # This is free software; you can redistribute it and/or modify it under
9 # the same terms as the Perl 5 programming language system itself.
10 #
11 # Full license text is available at:
12 #
13 # <http://dev.perl.org/licenses/>
14 #
15  
16 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Getopt::Long qw(GetOptions);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Markdown::Pod::Embed;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 $VERSION='1.011';
23  
24 1 my %opt;
25 GetOptions(
26 'inplace|i' => \$opt{'inplace'},
27 'recursive|recurse|r' => \$opt{'recursive'},
28 'dry-run' => \$opt{'dry_run'},
29 'nobackup' => \$opt{'nobackup'},
30 'dialect=s' => \$opt{'dialect'},
31 'extract-markdown|extract_markdown' => \$opt{'markdown'},
32 'extract-pod|extract_pod' => \$opt{'pod'},
33 'version' => \$opt{'version'},
34 1 ▶ 'help' => \$opt{'help'},
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions("inplace|i", \$opt{"inplace"}, "recursive|recurse|r", \$opt{"recursive"}, "dry-run", \$opt{"dry_run"}, "nobackup", \$opt{"nobackup"}, "dialect=s", \$opt{"dialect"}, "extract-markdown|extract_markdown", \$opt{"markdown"}, "extract-pod|extract_pod", \$opt{"pod"}, "version", \$opt{"version"}, "help", \$opt{"help"}) or die "invalid options; use --help\n" 1 0 1
35 ) or die "invalid options; use --help\n";
36 1 ▶if ($opt{'help'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{"help"}) 0 1 1
37 0 print "Usage: markpod [--inplace] [--recursive] [--dry-run] [--nobackup] FILE...\n";
38 0 print " markpod --extract-markdown|--extract-pod FILE\n";
39 0 exit 0;
40 }
41 1 ▶if ($opt{'version'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{"version"}) 0 1 1
42 0 print "markpod $VERSION\n";
43 0 exit 0;
44 }
45 1 ▶die "supply a file or directory\n" unless @ARGV;
Branch: 1 branch
BranchTrueFalseTotal
unless @ARGV 0 1 1
46 1 ▶die "choose one extraction mode\n" if $opt{'markdown'} && $opt{'pod'};
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"markdown"} and $opt{"pod"} 0 1 1
Condition33%1/3
$opt{"markdown"} and $opt{"pod"}
!ll&&!rl&&r
100
MC/DC0%0/2
$opt{"markdown"} and $opt{"pod"}
$opt{"markdown"} $opt{"pod"}
Truth table33%1/3
A and B
A= $opt{"markdown"}B= $opt{"pod"}
ABresult
0X0
100
111
47 1 ▶die "extraction cannot update files\n" if $opt{'inplace'} && ($opt{'markdown'} || $opt{'pod'});
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"inplace"} and $opt{"markdown"} || $opt{"pod"} 0 1 1
Condition16%1/6
$opt{"inplace"} and $opt{"markdown"} || $opt{"pod"}
!ll&&!rl&&r
100
$opt{"markdown"} or $opt{"pod"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$opt{"inplace"} and $opt{"markdown"} || $opt{"pod"}
$opt{"inplace"} $opt{"markdown"} $opt{"pod"}
Truth table25%1/4
A and B or C
A= $opt{"inplace"}B= $opt{"markdown"}C= $opt{"pod"}
ABCresult
0XX0
1000
11X1
1011
48 1 ▶die "directories require --recursive\n" if !$opt{'recursive'} && grep { -d $_ } @ARGV;
Branch: 1 branch
BranchTrueFalseTotal
if not $opt{"recursive"} and grep {-d $_;} @ARGV 0 1 1
Condition33%1/3
not $opt{"recursive"} and grep {-d $_;} @ARGV
!ll&&!rl&&r
010
MC/DC0%0/2
not $opt{"recursive"} and grep {-d $_;} @ARGV
not $opt{"recursive"} grep {-d $_;} @ARGV
Truth table33%1/3
not(A) and B
A= not $opt{"recursive"}B= grep {-d $_;} @ARGV
ABresult
0X0
100
111
49 1 my $file_ar=Markdown::Pod::Embed->discover(@ARGV);
50 1 ▶delete $opt{'dialect'} unless defined $opt{'dialect'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opt{"dialect"} 1 0 1
51 1 my $processor_or=Markdown::Pod::Embed->new(\%opt);
52 1 foreach my $fn (@{$file_ar}) {
53 1 my $changed=$processor_or->process($fn);
54 1 ▶ next unless defined $changed;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $changed 0 1 1
55 1 ▶ if ($opt{'dry_run'}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($opt{'dry_run'}) { } 1 0 1
elsif ($opt{'markdown'}) { } 0 0 0
elsif ($opt{'pod'}) { } 0 0 0
elsif ($opt{'inplace'}) { } 0 0 0
56 1 ▶ print "$fn: ", ($changed ? 'would update' : 'unchanged'), "\n";
Branch: 1 branch
BranchTrueFalseTotal
$changed ? : 0 1 1
57 }
58 0 elsif ($opt{'markdown'}) { print $processor_or->markdown() }
59 0 elsif ($opt{'pod'}) { print $processor_or->pod() }
60 0 ▶ elsif ($opt{'inplace'}) { $processor_or->markpod_inplace_update($fn) if $changed }
Branch: 1 branch
BranchTrueFalseTotal
if $changed 0 0 0
61 0 else { print $processor_or->ppi_doc_or()->serialize() }
62 }
63 __END__
64  
65 =begin markdown
66  
67 # NAME
68  
69 markpod - merge Markdown documentation into Perl files
70  
71 # USAGE
72  
73 `markpod --inplace --recursive lib bin` updates discovered source files.
74 `--dry-run` reports intended changes without writing. `--nobackup` suppresses
75 backup files. Without `--inplace`, complete transformed source is printed.
76  
77 Use `--extract-markdown FILE` or `--extract-pod FILE` to print documentation
78 only. `--dialect GitHub` selects the Markdown::Pod dialect.
79  
80 `--version` prints the installed program version.
81  
82 Supply files explicitly, or use `--recursive` with directories. Unsupported
83 options and failed operations exit nonzero. A file with no Markdown source is
84 skipped. See Markdown::Pod::Embed for source precedence and preservation rules.
85  
86 # AUTHOR
87  
88 Andrew Speer <andrew.speer@isolutions.com.au>
89  
90 # LICENSE and COPYRIGHT
91  
92 This file is part of Markdown::Pod::Embed.
93  
94 This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>.
95  
96 This is free software; you can redistribute it and/or modify it under
97 the same terms as the Perl 5 programming language system itself.
98  
99 Full license text is available at:
100  
101 <http://dev.perl.org/licenses/>
102  
103  
104 =end markdown
105  
106  
107 =head1 NAME
108  
109 markpod - merge Markdown documentation into Perl files
110  
111  
112 =head1 USAGE
113  
114 C<markpod --inplace --recursive lib bin> updates discovered source files.
115 C<--dry-run> reports intended changes without writing. C<--nobackup> suppresses
116 backup files. Without C<--inplace>, complete transformed source is printed.
117  
118 Use C<--extract-markdown FILE> or C<--extract-pod FILE> to print documentation
119 only. C<--dialect GitHub> selects the Markdown::Pod dialect.
120  
121 C<--version> prints the installed program version.
122  
123 Supply files explicitly, or use C<--recursive> with directories. Unsupported
124 options and failed operations exit nonzero. A file with no Markdown source is
125 skipped. See Markdown::Pod::Embed for source precedence and preservation rules.
126  
127  
128 =head1 AUTHOR
129  
130 Andrew Speer L<mailto:andrew.speer@isolutions.com.au>
131  
132  
133 =head1 LICENSE AND COPYRIGHT
134  
135 This software is copyright (c) 2026 by Andrew Speer. It may be distributed
136 under the same terms as Perl itself.
137  
138 =cut
« blib/lib/Markdown/Pod/Embed/Constant.pm ↑ Summary