]> git.donarmstrong.com Git - perltidy.git/commitdiff
update build.pl to scan for pod text in .pm files
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 5 Jan 2021 15:10:26 +0000 (07:10 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 5 Jan 2021 15:10:26 +0000 (07:10 -0800)
dev-bin/build.pl

index 05b36cff81058247fffe87756de1e72e82414212..5d34ed5b5b9f4f1584707fbcb416f2bfe2234af5 100755 (executable)
@@ -362,6 +362,9 @@ sub update_version_number {
 
     my $Tidy_pm_file = $lib_path . "Tidy.pm";
 
+    my $saw_pod = scan_for_pod( @sources );
+    return if ($saw_pod);
+
     # I have removed this one; it was useful in development
     # CS  Check that Selected files have the current VERSION
 
@@ -584,6 +587,65 @@ EOM
     return 1;
 }
 
+sub scan_for_pod {
+
+    # perltidy .pm files should not contain pod text
+    my (@sources) = @_;
+
+    foreach my $source_file (@sources) {
+
+        if ( !-f $source_file ) {
+            print <<EOM;
+Sorry, the following source file is not a file
+$source_file
+Please fix this to be the actual file and rerun
+EOM
+            return;
+        }
+
+        if ( -l $source_file ) {
+            print <<EOM;
+Sorry, the following file is a symlink
+$source_file
+I don't want to edit links; Please fix this to point to the actual file and rerun
+EOM
+            return;
+        }
+    }
+
+    my @files_with_pod;
+    while ( my $source_file = shift @sources ) {
+        next unless ( $source_file =~ /\.pm$/ );
+        my $result = qx/grep "^=cut" $source_file/;
+        if ($result) {
+           push @files_with_pod, $source_file;
+        }
+    }
+
+    my $saw_pod = @files_with_pod;
+print <<EOM;
+-------------------------------------------------------------------
+Scanning for pod in .pm files...
+EOM
+
+    if ($saw_pod) {
+        local $" = ') (';
+        query(<<EOM);
+Found files with pod text: (@files_with_pod);
+The convention in perltidy is not to have pod code in '.pm' files.
+Please remove the pod text before continuing, hit <cr> to continue
+-------------------------------------------------------------------
+EOM
+    }
+    else {
+        print <<EOM;
+OK - no pod text found in .pm files
+-------------------------------------------------------------------
+EOM
+    }
+
+    return $saw_pod;
+}
 sub make_tag_script {
     my ( $new_VERSION, $runme ) = @_;
     if ( open( RUN, ">$runme" ) ) {