Plan 9 from Bell Labs’s /usr/web/sources/contrib/gabidiaz/root/sys/src/cmd/perl/pod/splitpod

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/usr/bin/perl

use lib '../lib';  # If you haven't installed perl yet.
use Pod::Functions;

local $/ = '';

$cur = '';
while (<>) {

    next unless /^=(?!cut)/ .. /^=cut/;

    if (s/=item (\S+)/$1/) {
	#$cur = "POSIX::" . $1;
	$next{$cur} = $1;
	$cur = $1;
	$syn{$cur} .= $_;
	next;
    } else { 
	#s,L</,L<POSIX/,g;
	s,L</,L<perlfunc/,g;
	push @{$pod{$cur}}, $_ if $cur;
    }
} 

for $f ( keys %syn ) {
    next unless $Type{$f};
    $flavor = $Flavor{$f};
    $orig = $f;
    ($name = $f) =~ s/\W//g;

    # deal with several functions sharing a description
    $func = $orig;
    $func = $next{$func} until $pod{$func};
    my $body = join "", @{$pod{$func}};

    # deal with unbalanced =over and =back cause by the split
    my $has_over = $body =~ /^=over/;
    my $has_back = $body =~ /^=back/;
    $body =~ s/^=over\s*//m if $has_over and !$has_back;
    $body =~ s/^=back\s*//m if $has_back and !$has_over;
    open (POD, "> $name.pod") || die "can't open $name.pod: $!";
    print POD <<EOF;
=head1 NAME

$orig - $flavor

=head1 SYNOPSIS

$syn{$orig}

=head1 DESCRIPTION

$body

EOF

    close POD;

} 

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.