186 |
register_plugin_const ($_, \%Info); |
register_plugin_const ($_, \%Info); |
187 |
} elsif ($_->local_name eq 'Format') { |
} elsif ($_->local_name eq 'Format') { |
188 |
print "\n", make_format ($_, \%Info); |
print "\n", make_format ($_, \%Info); |
189 |
|
} elsif ($_->local_name eq 'FormattingRuleAlias') { |
190 |
|
print "\n", make_rule_alias ($_, \%Info); |
191 |
# Parameter |
# Parameter |
192 |
# PluginCategory |
# PluginCategory |
193 |
} |
} |
617 |
$r; |
$r; |
618 |
} |
} |
619 |
|
|
620 |
|
=item FormattingRuleAlias |
621 |
|
|
622 |
|
Generating an alias name for a formatting rule that is already loaded. |
623 |
|
Example: |
624 |
|
|
625 |
|
FormattingRuleAlias: |
626 |
|
@Category[list]: |
627 |
|
category-1 |
628 |
|
category-2 |
629 |
|
... |
630 |
|
@Name: new-rule-name |
631 |
|
@Reference: |
632 |
|
@@Category: one-of-category |
633 |
|
@@Name: one-of-name |
634 |
|
|
635 |
|
associates C<(I<category-1>, I<new-rule-name>)>, |
636 |
|
C<(I<category-2>, I<new-rule-name>)>, ... |
637 |
|
with C<(I<one-of-category>, I<one-of-name>)>. |
638 |
|
|
639 |
|
=cut |
640 |
|
|
641 |
|
sub make_rule_alias ($$) { |
642 |
|
my ($src, $Info) = @_; |
643 |
|
my $type = $src->get_attribute ('Category', make_new_node => 1)->value || []; |
644 |
|
my $name = $src->get_attribute ('Name', make_new_node => 1)->value; |
645 |
|
|
646 |
|
my $ref = $src->get_attribute ('Reference', make_new_node => 1); |
647 |
|
my $c = $ref->get_attribute_value ('Category'); |
648 |
|
my $n = $ref->get_attribute_value ('Name'); |
649 |
|
|
650 |
|
s/(?<=.)-/_/g for $n, $name; |
651 |
|
tr/-/_/ for $c, @$type; |
652 |
|
|
653 |
|
my $def = qq{\$SuikaWiki::Plugin::Rule{@{[literal $c]}}->{@{[literal $n]}} or warn qq{Formatting rule "$c/$n" not defined}}; |
654 |
|
|
655 |
|
my $r = change_package $Info, $Info->{module_name}; |
656 |
|
for my $type (@$type) { |
657 |
|
$r .= qq{\$SuikaWiki::Plugin::Rule{@{[literal $type]}}->{@{[literal $name]}} = $def;\n}; |
658 |
|
push @{$Info->{provide}->{rule}->{$type}}, $name; |
659 |
|
} |
660 |
|
$r; |
661 |
|
} |
662 |
|
|
663 |
|
|
664 |
sub random_module_name ($;$) { |
sub random_module_name ($;$) { |
665 |
my ($Info, $subname) = @_; |
my ($Info, $subname) = @_; |
670 |
sprintf ('%02d%02d%02d%02d%02d%02d', @date[5,4,3,2,1,0]), |
sprintf ('%02d%02d%02d%02d%02d%02d', @date[5,4,3,2,1,0]), |
671 |
join ('', @rand[rand@rand,rand@rand,rand@rand,rand@rand]); |
join ('', @rand[rand@rand,rand@rand,rand@rand,rand@rand]); |
672 |
} |
} |
673 |
|
|
674 |
|
=head1 NAME |
675 |
|
|
676 |
|
mkplugin2.pl - SuikaWiki: WikiPlugin Generator |
677 |
|
|
678 |
|
=head1 SYNOPSIS |
679 |
|
|
680 |
|
mkplugin2.pl pluginsrc.wp2 > plugin.pm |
681 |
|
|
682 |
|
=head1 DESCRIPTION |
683 |
|
|
684 |
|
C<mkplugin2.pl> generates WikiPlugin module as a Perl module file |
685 |
|
from WikiPlugin source description. WikiPlugin source description |
686 |
|
is described in SuikaWikiConfig/2.0 format and it contains |
687 |
|
definitions of wiki constructions (such as formatting rules and |
688 |
|
WikiView definitions) as both machine understandable code and |
689 |
|
human readable documentation. For more information, see |
690 |
|
<http://suika.fam.cx/~wakaba/-temp/wiki/wiki?WikiPlugin>. |
691 |
|
|
692 |
|
This script is part of SuikaWiki. |
693 |
|
|
694 |
|
=head1 HISTORY AND COMPATIBILITY |
695 |
|
|
696 |
|
C<mkplugin2.pl> introduced as part of SuikaWiki 3. |
697 |
|
It converts SuikaWiki 3 WikiPlugin source descriptions |
698 |
|
(in SuikaWikiConfig/2.0) into Perl modules with SuikaWiki 3 interface. |
699 |
|
|
700 |
|
SuikaWiki 2 has C<mkplugin.pl>. It also converts WikiPlugin |
701 |
|
source descriptions into Perl modules. But it support |
702 |
|
SuikaWiki 2 format of WikiPlugin source description that differs from |
703 |
|
SuikaWiki 3 format. Wiki programming interface (not limited to |
704 |
|
WikiPlugin related one) of SuikaWiki 3 also incompatible with that |
705 |
|
of SuikaWiki 2 so that it is impossible to use SuikaWiki 2 WikiPlugin |
706 |
|
module with SuikaWiki 3 and vice versa. |
707 |
|
|
708 |
|
=head1 SEE ALSO |
709 |
|
|
710 |
|
C<SuikaWiki::Plugin>, SuikaWiki:WikiPlugin |
711 |
|
<http://suika.fam.cx/~wakaba/-temp/wiki/wiki?WikiPlugin>. |
712 |
|
|
713 |
|
=head1 LICENSE |
714 |
|
|
715 |
|
Copyright 2003-2004 Wakaba <w@suika.fam.cx>. All rights reserved. |
716 |
|
|
717 |
|
This program is free software; you can redistribute it and/or |
718 |
|
modify it under the same terms as Perl itself. |
719 |
|
|
720 |
|
=cut |
721 |
|
|
722 |
|
1; # $Date$ |