@@ -49,21 +49,24 @@ =head1 DESCRIPTION
4949# These are the default sample problem directory and JSON file.
5050my $sample_prob_dir = " tutorial/sample-problems" ;
5151my $json_file = " htdocs/DATA/search.json" ;
52- my $verbose = 0 ;
52+ my ( $verbose , $show_warnings ) = (1, 0) ;
5353
5454GetOptions(
5555 ' p|pg-root=s' => \$pg_root ,
5656 ' f|json-file=s' => \$json_file ,
5757 ' s|sample-prob-dir=s' => \$sample_prob_dir ,
5858 ' b|build=s' => \$build ,
59+ ' w|show-warnings' => \$show_warnings ,
5960 ' v|verbose+' => \$verbose
6061);
6162
6263die " The build options must be one of (all, macros, samples). The value $build is not valid."
6364 if ((grep { $_ eq $build } qw/ all macros samples/ ) != 1);
6465
6566my $ww_root = $ENV {WW_ROOT };
66- $ww_root = Mojo::File-> new(curfile-> dirname, " .." , " .." )-> realpath unless defined ($ww_root );
67+ $ww_root = Mojo::File-> curfile-> dirname-> dirname-> realpath unless defined ($ww_root );
68+
69+ say $ww_root ;
6770
6871die " ww_root: $ww_root is not a directory" unless -d $ww_root ;
6972
@@ -99,7 +102,7 @@ =head1 DESCRIPTION
99102my @files ;
100103my $index = 1; # set an index for each file.
101104
102- sub processFile {
105+ sub processPGfile {
103106 return unless $_ =~ / \. pg$ / ;
104107 say " Processing $_ " if $verbose ;
105108 my $filename = $_ ;
@@ -192,11 +195,11 @@ sub extractPODNode {
192195 my ($filename , $root , $title ) = @_ ;
193196 my @index = grep { ref ($root -> [$_ ]) eq ' ARRAY' && $root -> [$_ ][2] =~ / $title / } 0 .. scalar (@$root ) - 1;
194197 if (@index == 0) {
195- warn " In $filename : The section named $title is not found in the POD." ;
198+ warn " In $filename : The section named $title is not found in the POD." if $show_warnings ;
196199 return ;
197200 }
198201 if (@index > 1) {
199- warn " In $filename : There are more than one section named $title in the POD." ;
202+ warn " In $filename : There are more than one section named $title in the POD." if $show_warnings ;
200203 return ;
201204 }
202205 # start at index 2 and extract all text
@@ -225,9 +228,12 @@ sub parseHead2 {
225228# process a macro file's POD
226229sub processMacro {
227230 return unless $_ =~ / \. pl$ / ;
228- say " Processing $_ " if $verbose ;
229231 my $file = Mojo::File-> new($File::Find::name );
230- return if $file -> dirname =~ / deprecated/ ;
232+ if ($file -> dirname =~ / deprecated/ ) {
233+ say " Skipping $_ . This is deprecated." if $verbose ;
234+ return ;
235+ }
236+ say " Processing $_ " if $verbose ;
231237
232238 my $parser = Pod::Simple::SimpleTree-> new();
233239 my $root = $parser -> parse_file(" $file " )-> root;
@@ -245,7 +251,7 @@ sub processMacro {
245251}
246252
247253# Process the sample problems in $sample_prob_dir.
248- find({ wanted => \&processFile }, " $sample_prob_dir " ) if (grep { $build eq $_ } qw/ all samples/ );
254+ find({ wanted => \&processPGfile }, " $sample_prob_dir " ) if (grep { $build eq $_ } qw/ all samples/ );
249255
250256# Process the POD within the macros dir.
251257find({ wanted => \&processMacro }, " $pg_root /macros" ) if (grep { $build eq $_ } qw/ all macros/ );
0 commit comments