Ticket #1227 (closed enhancement: wontfix)

Opened 3 years ago

Last modified 2 years ago

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

     
    2323use 5.008005; 
    2424use strict; 
    2525use warnings; 
    26 use Scalar::Util   (); 
     26use Scalar::Util (); 
    2727use FBP::Perl 0.38 (); 
    28 use Mouse     0.61; 
     28use Mouse 0.61; 
    2929 
    3030our $VERSION = '0.02'; 
    3131 
     
    4545    default  => 0, 
    4646); 
    4747 
    48  
    49  
    50  
    51  
    5248###################################################################### 
    5349# Dialog Generators 
    5450 
     
    5955    my $code    = $self->SUPER::dialog_class($name); 
    6056 
    6157    # Customise the package name if requested 
    62     if ( $package ) { 
     58    if ($package) { 
    6359        splice( @$code, 0, 1, "package $package;" ); 
    6460    } 
    6561 
    6662    # Prepend an auto-generated "Don't Modify" warning 
    6763    my $class = Scalar::Util::blessed($self); 
    6864    splice( 
    69         @$code, 1, 0, 
     65        @$code, 
     66        1, 
     67        0, 
    7068        "", 
    7169        "# This module was generated by $class.", 
    7270        "# To change this module, edit the original .fbp file and regenerate.", 
     
    7573 
    7674    # Append the copywrite statement that Debian/etc need 
    7775    push @$code, <<'END_PERL'; 
     76=pod 
     77 
     78=over 4 
     79 
     80=item new () 
     81 
     82Constructor. Auto-generated by Padre::Plugin::FormBuilder. 
     83 
     84=back 
     85 
     86=head1 AUTHOR 
    7887 
    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. 
     88Adam Kennedy E<lt>adamk@cpan.orgE<gt> 
     89 
     90=head1 SEE ALSO 
     91 
     92L<Padre> 
     93 
     94=head1 LICENSE AND COPYRIGHT 
     95 
     96Copyright (c) 2008-2011 The Padre development team as listed in Padre.pm. 
     97 
     98This module is free software; you can redistribute it and/or 
     99modify it under the same terms as Perl itself. 
     100 
     101=cut 
     102 
    83103END_PERL 
    84104 
    85105    return $code; 
     
    91111    my $lines  = $self->SUPER::dialog_new($dialog); 
    92112 
    93113    # 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' ); 
    97115 
    98116    if ( $self->encapsulate and @public ) { 
     117 
    99118        # 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) { 
    102121            my $name     = $window->name; 
    103122            my $variable = $self->object_variable($window); 
    104123            push @save, "\t\$self->{$name} = $variable->GetId;"; 
     
    116135    my $dialog  = shift; 
    117136    my $version = $self->version; 
    118137 
    119     return [ 
    120         "our \$VERSION = '$version';", 
    121     ]; 
     138    return [ "our \$VERSION = '$version';", ]; 
    122139} 
    123140 
    124141sub dialog_isa { 
     
    126143    my $dialog = shift; 
    127144 
    128145    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",          "};", 
    133148    ); 
    134149} 
    135150 
    136151sub use_wx { 
    137152    my $self   = shift; 
    138153    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 ();", ]; 
    143155} 
    144156 
    145157sub window_accessor { 
     
    150162 
    151163    my $object = shift; 
    152164    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( 
    154182        "sub $name {", 
    155         "Wx::Window::FindWindowById(\$_[0]->{$name});", 
    156         "}", 
     183        "Wx::Window::FindWindowById(\$_[0]->{$name});", "}", 
    157184    ); 
     185 
     186    my @conjoined = ( @tmp_pod, @tmp_accessor_method ); 
     187    return @conjoined; 
    158188} 
    159189 
    160190sub window_event { 
     
    163193    my $event  = shift; 
    164194    my $name   = $window->name; 
    165195    my $method = $window->$event(); 
     196    my $space  = q{ }; 
    166197 
    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( 
    168214        "sub $method {", 
    169215        "\$_[0]->main->error('Handler method $method for event $name.$event not implemented');", 
    170216        "}", 
    171217    ); 
     218 
     219    my @conjoined = ( @tmp_pod, @tmp_required_method ); 
     220    return @conjoined; 
    172221} 
    173222 
    174223# Because we expect everything to be shimmed, apply a stricter interpretation 

Change History

comment:1 Changed 3 years ago by bowtie

  • Status changed from new to assigned
  • Component changed from not classified yet to plugins
  • Summary changed from Padre::Plugin::FormBuilder::Perl to Padre::Plugin::FormBuilder::Perl, patch to add POD to plugin dialogs

comment:2 Changed 2 years ago by adamk

  • Status changed from assigned to closed
  • Resolution set to wontfix

While I like the idea in principle, the quality of the documentation is nearly useless. It should provide much more information.

Rejecting this patch, although I do like the idea.

Note: See TracTickets for help on using tickets.