Ticket #1227 (closed enhancement: wontfix)
Padre::Plugin::FormBuilder::Perl, patch to add POD to plugin dialogs
| Reported by: | bowtie | Owned by: | Alias |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | plugins | Version: | 0.84 |
| Keywords: | Plugin | Cc: |
Description
Added auto POD generation.
-
lib/Padre/Plugin/FormBuilder/Perl.pm
23 23 use 5.008005; 24 24 use strict; 25 25 use warnings; 26 use Scalar::Util ();26 use Scalar::Util (); 27 27 use FBP::Perl 0.38 (); 28 use Mouse 0.61;28 use Mouse 0.61; 29 29 30 30 our $VERSION = '0.02'; 31 31 … … 45 45 default => 0, 46 46 ); 47 47 48 49 50 51 52 48 ###################################################################### 53 49 # Dialog Generators 54 50 … … 59 55 my $code = $self->SUPER::dialog_class($name); 60 56 61 57 # Customise the package name if requested 62 if ( $package) {58 if ($package) { 63 59 splice( @$code, 0, 1, "package $package;" ); 64 60 } 65 61 66 62 # Prepend an auto-generated "Don't Modify" warning 67 63 my $class = Scalar::Util::blessed($self); 68 64 splice( 69 @$code, 1, 0, 65 @$code, 66 1, 67 0, 70 68 "", 71 69 "# This module was generated by $class.", 72 70 "# To change this module, edit the original .fbp file and regenerate.", … … 75 73 76 74 # Append the copywrite statement that Debian/etc need 77 75 push @$code, <<'END_PERL'; 76 =pod 77 78 =over 4 79 80 =item new () 81 82 Constructor. Auto-generated by Padre::Plugin::FormBuilder. 83 84 =back 85 86 =head1 AUTHOR 78 87 79 # Copyright 2008-2011 The Padre development team as listed in Padre.pm. 80 # LICENSE 81 # This program is free software; you can redistribute it and/or 82 # modify it under the same terms as Perl 5 itself. 88 Adam Kennedy E<lt>adamk@cpan.orgE<gt> 89 90 =head1 SEE ALSO 91 92 L<Padre> 93 94 =head1 LICENSE AND COPYRIGHT 95 96 Copyright (c) 2008-2011 The Padre development team as listed in Padre.pm. 97 98 This module is free software; you can redistribute it and/or 99 modify it under the same terms as Perl itself. 100 101 =cut 102 83 103 END_PERL 84 104 85 105 return $code; … … 91 111 my $lines = $self->SUPER::dialog_new($dialog); 92 112 93 113 # Find the full list of public windows 94 my @public = grep { 95 $_->permission eq 'public' 96 } $dialog->find( isa => 'FBP::Window' ); 114 my @public = grep { $_->permission eq 'public' } $dialog->find( isa => 'FBP::Window' ); 97 115 98 116 if ( $self->encapsulate and @public ) { 117 99 118 # Generate code to save the wxWidgets id values to the hash slots 100 my @save = ( '');101 foreach my $window ( @public) {119 my @save = (''); 120 foreach my $window (@public) { 102 121 my $name = $window->name; 103 122 my $variable = $self->object_variable($window); 104 123 push @save, "\t\$self->{$name} = $variable->GetId;"; … … 116 135 my $dialog = shift; 117 136 my $version = $self->version; 118 137 119 return [ 120 "our \$VERSION = '$version';", 121 ]; 138 return [ "our \$VERSION = '$version';", ]; 122 139 } 123 140 124 141 sub dialog_isa { … … 126 143 my $dialog = shift; 127 144 128 145 return $self->nested( 129 "our \@ISA = qw{", 130 "Padre::Wx::Role::Main", 131 "Wx::Dialog", 132 "};", 146 "our \@ISA = qw{", "Padre::Wx::Role::Main", 147 "Wx::Dialog", "};", 133 148 ); 134 149 } 135 150 136 151 sub use_wx { 137 152 my $self = shift; 138 153 my $dialog = shift; 139 return [ 140 "use Padre::Wx ();", 141 "use Padre::Wx::Role::Main ();", 142 ]; 154 return [ "use Padre::Wx ();", "use Padre::Wx::Role::Main ();", ]; 143 155 } 144 156 145 157 sub window_accessor { … … 150 162 151 163 my $object = shift; 152 164 my $name = $object->name; 153 return $self->nested( 165 my $space = q{ }; 166 167 my @tmp_pod = [ 168 "=pod", 169 "$space", 170 "=over 4", 171 "$space", 172 "=item $name ()", 173 "$space", 174 "Public Accessor $name Auto-generated.", 175 "$space", 176 "=back", 177 "$space", 178 "=cut", 179 ]; 180 181 my @tmp_accessor_method = $self->nested( 154 182 "sub $name {", 155 "Wx::Window::FindWindowById(\$_[0]->{$name});", 156 "}", 183 "Wx::Window::FindWindowById(\$_[0]->{$name});", "}", 157 184 ); 185 186 my @conjoined = ( @tmp_pod, @tmp_accessor_method ); 187 return @conjoined; 158 188 } 159 189 160 190 sub window_event { … … 163 193 my $event = shift; 164 194 my $name = $window->name; 165 195 my $method = $window->$event(); 196 my $space = q{ }; 166 197 167 return $self->nested( 198 my @tmp_pod = [ 199 "=pod", 200 "$space", 201 "=over 4", 202 "$space", 203 "=item $method ()", 204 "$space", 205 "Event Handler for $name.$event (Required). Auto-generated.", 206 "You must implement this Method in your calling class.", 207 "$space", 208 "=back", 209 "$space", 210 "=cut", 211 ]; 212 213 my @tmp_required_method = $self->nested( 168 214 "sub $method {", 169 215 "\$_[0]->main->error('Handler method $method for event $name.$event not implemented');", 170 216 "}", 171 217 ); 218 219 my @conjoined = ( @tmp_pod, @tmp_required_method ); 220 return @conjoined; 172 221 } 173 222 174 223 # Because we expect everything to be shimmed, apply a stricter interpretation
Change History
Note: See
TracTickets for help on using
tickets.
