#!/usr/bin/perl use strict; my %ReplaceText = &ReplaceText; my %Info; my $mode = 0; my $section = ''; my %item; while (<>) { if ($mode == 1) { ## In a block if (/^\}$/) { $item{ModuleName} ||= $item{Name}; $item{ModuleName} =~ s/[^0-9A-Za-z_]/_/g; push @{ $Info{part} }, {%item}; $mode = 0; %item = (); } elsif (/^(.+):$/) { $section = $1; } elsif (/^\t(.*)$/) { my $l = $1; if ($item{$section}) { $item{$section} .= "\n".$l; } else { $item{$section} = $l; } } } else { ## Out of blocks if (/^\{$/) { $mode = 1; } elsif (/^(.+):$/) { $section = $1; } elsif (/^\t(.*)$/) { my $t = $1; if ($Info{$section}) { $Info{$section} .= "\n".$t; } else { $Info{$section} = $t; } } } } $ReplaceText{MYSELF} = qq(SuikaWiki::Plugin::$Info{Name}); print < @{[ $Info{'POD:DESCRIPTION'} ? qq{ =head1 DESCRIPTION $Info{'POD:DESCRIPTION'}} : '']} =cut package $ReplaceText{MYSELF}; use strict; our \$VERSION = q(@{[sprintf '%04d.%02d%02d.%02d%02d', (gmtime)[5]+1900, (gmtime)[4]+1, (gmtime)[3,2,1]]}); EOH my %part; my $partinfo; for my $fullpart (@{ $Info{part} }) { my ($type, $part) = split m#/#, $fullpart->{Name}, 2; $part{$type}->{$part} = <{FullName} \$fmt->{$part} = sub { my (\$r, \$p, \$o) = ('', \@_); $fullpart->{Format} \$r }; EOH $partinfo .= < q($fullpart->{FullName}), EOH } my $provide = qq(qw/@{([join ' ', keys %part])}/); print <SuikaWiki::Plugin::regist ($provide); } sub property (\$;\@) { shift; my \%prop = ( name => q($Info{FullName}), version => \$VERSION, uri => q($Info{URI}), provide => [$provide], partinfo => { $partinfo}, ); if (scalar \@_ == 0) { \\\%prop; } else { \@prop{\@_}; } } EOH print <<'EOH'; sub load_formatter ($$%) { my $self = shift; my ($fmt, %q) = @_; unless ($q{type}) { # } EOH for my $part (sort keys %part) { print <{$name} EOH } print <<'EOH'; } EOH } print < q{This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.}, PerlLicense => q{This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.}, YEAR => (gmtime)[5]+1900, ); %RT; } =head1 LICENSE Copyright 2002 Wakaba This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Note that modules generated by this script should be licensed by the licenser of source file so that copyright holder of this script does not claim any right to them. =cut 1; # $Date: 2002/12/05 04:29:59 $