Tweaks and reflowing for the cc/linker split.
[p5sagit/p5-mst-13.2.git] / pod / perlmodlib.PL
index b7e5bf3..39e9613 100644 (file)
@@ -10,36 +10,57 @@ open (MANIFEST, "../MANIFEST") or die $!;
 push @MANIFEST, 'lib/Config.pod', 'lib/Errno.pm', 'lib/lib.pm',
     'lib/DynaLoader.pm', 'lib/XSLoader.pm';
 
--f "../lib/DynaLoader.pm" or die "Must be run from a source tree where perl has been built\n";
+# If run in a clean source tree, these will be missing because they are
+# generated by the build.
+my %generated = (
+    'encoding' => 'Allows you to write your script in non-ascii or non-utf8',
+    'lib' => 'Manipulate @INC at compile time',
+    'ops' => 'Restrict unsafe operations when compiling',
+    'Config' => 'Access Perl configuration information',
+    'DynaLoader' => 'Dynamically load C libraries into Perl code',
+    'Errno' => 'System errno constants',
+    'O' => 'Generic interface to Perl Compiler backends',
+    'Safe' => 'Compile and execute code in restricted compartments',
+    'XSLoader' => 'Dynamically load C libraries into Perl code',
+);
+
+# If run in a clean source tree, these should not be reported.
+# These are considered 'modules' by this script, but they really are not.
+my %suppressed = map {$_ => 1} qw(
+    B::O
+    Encode::encoding
+    Opcode::Safe
+    Opcode::ops
+);
 
 for (@MANIFEST) {
-     my $filename;
-     next unless s|^lib/|| or m|^ext/|;
-     my ($origfilename) = ($filename) = m|^(\S+)|;
-     $filename =~ s|^[^/]+/|| if $filename =~ s|^ext/||;
-     next unless $filename =~ m!\.p(m|od)$!;
-     unless (open (MOD, "../lib/$filename")) {
-       unless (open (MOD, "../$origfilename")) {
-           warn "Couldn't open ../$origfilename: $!";
-           next;
-       }
-       $filename = $origfilename;
-     }
+    my $filename;
+    next unless s|^lib/|| or m|^ext/|;
+    my ($origfilename) = ($filename) = m|^(\S+)|;
+    $filename =~ s|^[^/]+/|| if $filename =~ s|^ext/||;
+    next unless $filename =~ m!\.p(m|od)$!;
+    unless (open (MOD, "../lib/$filename")) {
+        unless (open (MOD, "../$origfilename")) {
+            warn "Couldn't open ../$origfilename: $!";
+            next;
+        }
+        $filename = $origfilename;
+    }
 
 
      my ($name, $thing);
      my $foundit=0;
      {
-        local $/="";
-        while (<MOD>) {
-            next unless /^=head1 NAME/;
-            $foundit++;
-            last;
-        }
+         local $/="";
+         while (<MOD>) {
+             next unless /^=head1 NAME/;
+             $foundit++;
+             last;
+         }
      }
      unless ($foundit) {
-        warn "$filename missing =head1 NAME (okay if there is respective .pod)\n";
-        next;
+         warn "$filename missing =head1 NAME (OK if respective .pod exists)\n";
+         next;
      }
      my $title = <MOD>;
      chomp($title);
@@ -57,11 +78,12 @@ for (@MANIFEST) {
      ($name, $thing) = split / --? /, $title, 2;
 
      unless ($name and $thing) {
-        warn "$filename missing name\n"  unless $name;
-        warn "$filename missing thing\n" unless $thing;
-        next;
+         warn "$filename missing name\n"  unless $name;
+         warn "$filename missing thing\n" unless $thing;
+         next;
      }
 
+     next if $suppressed{$perlname};
 
      $thing =~ s/^perl pragma to //i;
      $thing = ucfirst($thing);
@@ -72,6 +94,17 @@ for (@MANIFEST) {
      } else {
           push @pragma, $title;
      }
+
+     # if we find a generated one via the MANIFEST, no need to add later.
+     delete $generated{$perlname};
+}
+while (my ($name,$desc) = each %generated) {
+    my $title = "=item $name\n\n$desc\n\n";
+    if ($name =~ /[A-Z]/) {
+        push @mod, $title;
+    } else {
+        push @pragma, $title;
+    }
 }
 
 print OUT <<'EOF';