@@ -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
@@ -73,6 +76,7 @@ =head1 DESCRIPTION
7376my $json_dir = $json_file -> dirname;
7477$json_dir -> make_path unless -d $json_dir ;
7578
79+
7680if ($verbose ) {
7781 say " Running script build-search-data with the following options:" ;
7882 say " pg-root: $pg_root " ;
@@ -99,7 +103,7 @@ =head1 DESCRIPTION
99103my @files ;
100104my $index = 1; # set an index for each file.
101105
102- sub processFile {
106+ sub processPGfile {
103107 return unless $_ =~ / \. pg$ / ;
104108 say " Processing $_ " if $verbose ;
105109 my $filename = $_ ;
@@ -192,11 +196,11 @@ sub extractPODNode {
192196 my ($filename , $root , $title ) = @_ ;
193197 my @index = grep { ref ($root -> [$_ ]) eq ' ARRAY' && $root -> [$_ ][2] =~ / $title / } 0 .. scalar (@$root ) - 1;
194198 if (@index == 0) {
195- warn " In $filename : The section named $title is not found in the POD." ;
199+ warn " In $filename : The section named $title is not found in the POD." if $show_warnings ;
196200 return ;
197201 }
198202 if (@index > 1) {
199- warn " In $filename : There are more than one section named $title in the POD." ;
203+ warn " In $filename : There are more than one section named $title in the POD." if $show_warnings ;
200204 return ;
201205 }
202206 # start at index 2 and extract all text
@@ -225,9 +229,12 @@ sub parseHead2 {
225229# process a macro file's POD
226230sub processMacro {
227231 return unless $_ =~ / \. pl$ / ;
228- say " Processing $_ " if $verbose ;
229232 my $file = Mojo::File-> new($File::Find::name );
230- return if $file -> dirname =~ / deprecated/ ;
233+ if ($file -> dirname =~ / deprecated/ ){
234+ say " Skipping $_ . This is deprecated." if $verbose ;
235+ return ;
236+ }
237+ say " Processing $_ " if $verbose ;
231238
232239 my $parser = Pod::Simple::SimpleTree-> new();
233240 my $root = $parser -> parse_file(" $file " )-> root;
@@ -245,7 +252,7 @@ sub processMacro {
245252}
246253
247254# Process the sample problems in $sample_prob_dir.
248- find({ wanted => \&processFile }, " $sample_prob_dir " ) if (grep { $build eq $_ } qw/ all samples/ );
255+ find({ wanted => \&processPGfile }, " $sample_prob_dir " ) if (grep { $build eq $_ } qw/ all samples/ );
249256
250257# Process the POD within the macros dir.
251258find({ wanted => \&processMacro }, " $pg_root /macros" ) if (grep { $build eq $_ } qw/ all macros/ );
0 commit comments