[Bps-public-commit] Shipwright branch, master, updated. 363d4f6ea7057630ce69a7d9b76a206654e8c26e

Ruslan Zakirov ruz at bestpractical.com
Fri Sep 11 07:51:33 EDT 2009


The branch, master has been updated
       via  363d4f6ea7057630ce69a7d9b76a206654e8c26e (commit)
       via  3172814be4fba72a8d0f55b7bd5eb1ef9836d401 (commit)
       via  51fc7f7ea1c7efc54c57a16a91f782298a9cdd01 (commit)
       via  18ec99a44d59e109d86af41c0e6c1ad2bdfe27f6 (commit)
       via  bbafbf9970e26f35a9ae2a745020bde94f92ba53 (commit)
      from  0a0238c6810f7507a67a07d7119d758da6505436 (commit)

Summary of changes:
 lib/Shipwright/Backend.pm          |   59 ++++------
 lib/Shipwright/Backend/FS.pm       |    7 +-
 lib/Shipwright/Backend/Git.pm      |   15 ++-
 lib/Shipwright/Backend/SVK.pm      |   17 +++-
 lib/Shipwright/Backend/SVN.pm      |   17 +++-
 lib/Shipwright/Manual/ENV.pod      |   13 +--
 lib/Shipwright/Manual/Tutorial.pod |   74 +++++++-----
 lib/Shipwright/Source.pm           |    6 +
 xbin/update_pod.pl                 |  230 ++++++++++++++++++++++++++++++++++++
 9 files changed, 355 insertions(+), 83 deletions(-)
 create mode 100644 xbin/update_pod.pl

- Log -----------------------------------------------------------------
commit bbafbf9970e26f35a9ae2a745020bde94f92ba53
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Sep 11 13:34:13 2009 +0400

    * update backends docs

diff --git a/lib/Shipwright/Backend.pm b/lib/Shipwright/Backend.pm
index b98c7eb..fb1e763 100644
--- a/lib/Shipwright/Backend.pm
+++ b/lib/Shipwright/Backend.pm
@@ -53,55 +53,36 @@ Shipwright::Backend - Backend
 
 =head1 SYNOPSIS
 
-use Shipwright::Backend;
-$backend = Shipwright::Backend->new(repository => $args{repository});
+    # shipwright some_command -r backend_type:path
+    shipwright create -r svn:file:///svnrepo/shipwright/my_proj
 
-=head1 METHODS
+    use Shipwright::Backend;
+    $backend = Shipwright::Backend->new(repository => $args{repository});
 
-=over
+=head1 DESCRIPTION
 
-=item new
+See <Shipwright::Manual::Glossary/repository> to understand concept. Look
+at list of </SUPPORTED BACKENDS> and L<IMPLEMENTING BACKENDS> if you want
+add a new one.
 
-returns the Backend object that corresponds to the type in
-$args{repository}.
+=head1 SUPPORTED BACKENDS
 
 Currently, the supported backends are FS, SVN and SVK.
 
-=item initialize
-
-=item import
-
-=item export
-
-=item checkout
-
-=item commit
-
-=item update_order
-
-=item order
-
-=item map
+=head1 IMPLEMENTING BACKENDS
 
-=item source
+Each implementation of a backend is a subclass of L<Shipwright::Backend::Base>.
 
-=item delete
-
-=item info
-
-=item test_script
-
-=item requires
-
-=item flags
-
-=item version
+=head1 METHODS
 
-=item check_repository
+This is a tiny class with only one method C<new> that loads
+particular implementation class and returns instance of that
+class.
 
-=item update
+=head2 new repository => "type:path"
 
-=back
+Returns the backend object that corresponds to the type
+defined in the repository argument.
 
 =head1 AUTHORS
 
@@ -113,3 +94,5 @@ Shipwright is Copyright 2007-2009 Best Practical Solutions, LLC.
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.
+
+=cut
diff --git a/lib/Shipwright/Backend/FS.pm b/lib/Shipwright/Backend/FS.pm
index c65f1f1..d2ec094 100644
--- a/lib/Shipwright/Backend/FS.pm
+++ b/lib/Shipwright/Backend/FS.pm
@@ -16,9 +16,14 @@ use base qw/Shipwright::Backend::Base/;
 
 Shipwright::Backend::FS - File System backend
 
+=head1 SYNOPSIS
+
+    shipwright create -r fs:/home/me/shipwright/my_project
+
 =head1 DESCRIPTION
 
-This module implements file system backend
+This module implements file system based backend with version control
+for Shipwright L<repository|Shipwright::Manual::Glossary/repository>.
 
 =head1 METHODS
 
diff --git a/lib/Shipwright/Backend/Git.pm b/lib/Shipwright/Backend/Git.pm
index 8a0e90d..825adb1 100644
--- a/lib/Shipwright/Backend/Git.pm
+++ b/lib/Shipwright/Backend/Git.pm
@@ -19,9 +19,22 @@ use base qw/Shipwright::Backend::Base/;
 
 Shipwright::Backend::Git - Git repository backend
 
+=head1 SYNOPSIS
+
+    shipwright create -r git:file:///home/me/shipwright/my_proj.git
+
 =head1 DESCRIPTION
 
-This module implements an Git repository backend for Shipwright.
+This module implements a Git based backend
+for Shipwright L<repository|Shipwright::Manual::Glossary/repository>.
+
+=head1 ENVIRONMENT VARIABLES
+
+=over 4
+
+=item SHIPWRIGHT_GIT - path of F<git> command, default value is F<git>.
+
+=back
 
 =head1 METHODS
 
diff --git a/lib/Shipwright/Backend/SVK.pm b/lib/Shipwright/Backend/SVK.pm
index 1e715fd..49aebb1 100644
--- a/lib/Shipwright/Backend/SVK.pm
+++ b/lib/Shipwright/Backend/SVK.pm
@@ -16,9 +16,24 @@ use base qw/Shipwright::Backend::Base/;
 
 Shipwright::Backend::SVK - SVK repository backend
 
+=head1 SYNOPSIS
+
+    shipwright create -r svk:/depot/shipwright/my_proj
+
 =head1 DESCRIPTION
 
-This module implements an SVK repository backend for Shipwright.
+This module implements an L<SVK> based backend
+for Shipwright L<repository|Shipwright::Manual::Glossary/repository>.
+
+=head1 ENVIRONMENT VARIABLES
+
+=over 4
+
+=item SHIPWRIGHT_SVK - path of F<svk> command, default value is F<svk>.
+
+=back
+
+L<Shipwright::Manual::ENV/SHIPWRIGHT_SVN> can be used as well.
 
 =head1 METHODS
 
diff --git a/lib/Shipwright/Backend/SVN.pm b/lib/Shipwright/Backend/SVN.pm
index 2f1398e..c6a2c34 100644
--- a/lib/Shipwright/Backend/SVN.pm
+++ b/lib/Shipwright/Backend/SVN.pm
@@ -15,9 +15,24 @@ use base qw/Shipwright::Backend::Base/;
 
 Shipwright::Backend::SVN - SVN repository backend
 
+=head1 SYNOPSIS
+
+    svnadmin create /home/me/shipwright/my_proj
+    shipwright create -r svn:file:///home/me/shipwright/my_proj
+
 =head1 DESCRIPTION
 
-This module implements a SVN repository backend for Shipwright.
+This module implements a SVN based backend
+for Shipwright L<repository|Shipwright::Manual::Glossary/repository>.
+
+=head1 ENVIRONMENT VARIABLES
+
+=over 4
+
+=item SHIPWRIGHT_SVN - path of F<svn> command, default value is F<svn>.
+F<svnadmin> command is expected to be in the same directory as F<svn>.
+
+=back
 
 =head1 METHODS
 

commit 18ec99a44d59e109d86af41c0e6c1ad2bdfe27f6
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Sep 11 14:15:51 2009 +0400

    update list of backends using cool tool

diff --git a/lib/Shipwright/Backend.pm b/lib/Shipwright/Backend.pm
index fb1e763..93fd28d 100644
--- a/lib/Shipwright/Backend.pm
+++ b/lib/Shipwright/Backend.pm
@@ -67,7 +67,7 @@ add a new one.
 
 =head1 SUPPORTED BACKENDS
 
-Currently, the supported backends are FS, SVN and SVK.
+Currently, the supported backends are L<FS|Shipwright::Backend::FS>, L<Git|Shipwright::Backend::Git>, L<SVK|Shipwright::Backend::SVK> and L<SVN|Shipwright::Backend::SVN>.
 
 =head1 IMPLEMENTING BACKENDS
 

commit 51fc7f7ea1c7efc54c57a16a91f782298a9cdd01
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Sep 11 15:10:22 2009 +0400

    update files using the tool

diff --git a/lib/Shipwright/Backend.pm b/lib/Shipwright/Backend.pm
index 93fd28d..1135a5e 100644
--- a/lib/Shipwright/Backend.pm
+++ b/lib/Shipwright/Backend.pm
@@ -67,7 +67,7 @@ add a new one.
 
 =head1 SUPPORTED BACKENDS
 
-Currently, the supported backends are L<FS|Shipwright::Backend::FS>, L<Git|Shipwright::Backend::Git>, L<SVK|Shipwright::Backend::SVK> and L<SVN|Shipwright::Backend::SVN>.
+Currently, the supported backends are L<FS|Shipwright::BACKEND::FS>, L<Git|Shipwright::BACKEND::Git>, L<SVK|Shipwright::BACKEND::SVK> and L<SVN|Shipwright::BACKEND::SVN>.
 
 =head1 IMPLEMENTING BACKENDS
 
diff --git a/lib/Shipwright/Manual/ENV.pod b/lib/Shipwright/Manual/ENV.pod
index 70f6a73..9ca20e8 100644
--- a/lib/Shipwright/Manual/ENV.pod
+++ b/lib/Shipwright/Manual/ENV.pod
@@ -35,17 +35,12 @@ user's home directory, e.g. /home/joe
     LWP timeout( seconds ).
     technically, it's the seconds we take to call $ua->timeout($seconds)
 
-=item SHIPWRIGHT_SVK
+=item SHIPWRIGHT_SVK - path of F<svk> command, default value is F<svk>.
 
-    path of 'svk' cmd, default value is 'svk'
+=item SHIPWRIGHT_SVN - path of F<svn> command, default value is F<svn>.
+F<svnadmin> command is expected to be in the same directory as F<svn>.
 
-=item SHIPWRIGHT_SVN
-
-    path of 'svn' cmd, default value is 'svn'
-
-=item SHIPWRIGHT_GIT
-
-    path of 'git' cmd, default value is 'git'
+=item SHIPWRIGHT_GIT - path of F<git> command, default value is F<git>.
 
 =item SHIPWRIGHT_TEST_SVK
 
diff --git a/lib/Shipwright/Source.pm b/lib/Shipwright/Source.pm
index 301fcf6..2e677fa 100644
--- a/lib/Shipwright/Source.pm
+++ b/lib/Shipwright/Source.pm
@@ -15,8 +15,14 @@ Shipwright::Source - Source
 
 =head1 SYNOPSIS
 
+    shipwright import -r ... cpan:XML::LibXML
+
     use Shipwright::Source;
 
+=head1 SUPPORTED SOURCES
+
+Currently, the supported sources are L<CPAN|Shipwright::SOURCE::CPAN>, L<Compressed|Shipwright::SOURCE::Compressed>, L<Directory|Shipwright::SOURCE::Directory>, L<FTP|Shipwright::SOURCE::FTP>, L<Git|Shipwright::SOURCE::Git>, L<HTTP|Shipwright::SOURCE::HTTP>, L<SVK|Shipwright::SOURCE::SVK>, L<SVN|Shipwright::SOURCE::SVN> and L<Shipwright|Shipwright::SOURCE::Shipwright>.
+
 =head1 METHODS
 
 =head2 new

commit 3172814be4fba72a8d0f55b7bd5eb1ef9836d401
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Sep 11 15:12:40 2009 +0400

    update tutorial

diff --git a/lib/Shipwright/Manual/Tutorial.pod b/lib/Shipwright/Manual/Tutorial.pod
index e10a15a..b00124d 100644
--- a/lib/Shipwright/Manual/Tutorial.pod
+++ b/lib/Shipwright/Manual/Tutorial.pod
@@ -2,30 +2,27 @@
 
 Shipwright::Manual::Tutorial - Tutorial to Shipwright
 
-=head1 SYNOPSIS
+=head1 DESCRIPTION
 
 In this tutorial, we'll create a vessel to represent basic stuff of Shipwright.
 
-=head1 DESCRIPTION
+=head1 TUTORIAL
 
-Currently, Shipwright supports 4 kinds of backends: I<SVK>, I<SVN>, I<Git> and I<plain
-file system>. e.g.
+=head1 Introduction
 
-    svn:file:///tmp/svnrepo/foo
-    svn:http://svn.example.com/foo
-    svk://foo
-    svk:/test/foo
-    git:file:///tmp/shipwright.git
-    fs:/tmp/foo
+Shipwright is shipped with command line tool F<shipwright> which allow you to manage
+shipwright repositories: L<create|/Create a new repository>,
+L<import dists|/Importing dists into the repository> and L</update>.
 
-Note: since we need C<svk>/C<svn>/C<svnadmin>/C<git> cmds in in backends, sources or 
-other places, we can tell shipwright the location of C<svk>/C<svn>/C<git> cmds by 
-setting ENV C<SHIPWRIGHT_SVK>/C<SHIPWRIGHT_SVN>/C<SHIPWRIGHT_GIT>.
-C<svnadmin> is assumed in the same directory of svn. 
+Let's start from a new repository.
 
-we'll use C<svn:file:///tmp/svnrepo/foo> as the repository for the rest tutorial.
+=head2 Create a new repository
 
-=head2 create
+Repository - the backend, where all stuff lives, e.g. metadata, sources, etc...
+Shipwright supports several backends: L<SVK|Shipwright::Backend::SVK>,
+L<SVN|Shipwright::Backend::SVN>, L<Git|Shipwright::Backend::Git> and
+L<plain file system|Shipwright::Backend::FS>. We'll use SVN backend for
+our repository in this tutorial.
 
 We need to create the svn repo first:
 
@@ -35,17 +32,26 @@ Then we can initialize the repository of our Shipwright project:
 
     $ shipwright create -r svn:file:///tmp/svnrepo/foo
 
-For the layout of shipwright's source, see L<Shipwright>.
+If F<svn> executable is not under PATH then you can tell shipwright
+the location of it by setting enviroment variable "SHIPWRIGHT_SVN".
+F<svnadmin> is assumed in the same directory as F<svn>.
 
-=head2 import
+=head2 Don't repeat -r argument
 
-It's worthless if we don't import some dists to Shipwright, let's do it now.
+To avoid typing I<-r svn:file:///tmp/svnrepo/foo> all the time you
+can use "SHIPWRIGHT_REPOSITORY" environment variable.
 
-Shipwright supports 8 kinds of sources:
+    export SHIPWRIGHT_REPOSITORY="svn:file:///tmp/svnrepo/foo"
 
-here're some examples:
+Done. No more -r ... for the session.
 
-B<Caveat>: for files, we only support I<.tar.gz>(I<.tgz>) and I<.tar.bz2> format currently.
+=head2 Import dists into the repository
+
+Our repository is worthless if we don't import some dists. let's do
+it now.
+
+Shipwright supports different sources you can import things from.
+Here're some examples:
 
 =over 4
 
@@ -54,6 +60,8 @@ B<Caveat>: for files, we only support I<.tar.gz>(I<.tgz>) and I<.tar.bz2> format
     file:/tmp/foo.tar.gz
     file:/home/ross/dinosaur-0.01.tar.bz2
 
+B<Caveat>: for files, we only support I<.tar.gz>(I<.tgz>) and I<.tar.bz2> format currently.
+
 =item plain directory
 
     dir:/tmp/foo
@@ -101,13 +109,13 @@ dist name we want to import.
 We'll import apache 2.2.9, perl 5.10, mod_perl 2.0, libxml and XML::LibXML
 in this tutorial one by one.
 
-    $ shipwright import -r svn:file:///tmp/svnrepo/foo http://www.apache.org/dist/httpd/httpd-2.2.9.tar.gz --name apache
-    $ shipwright import -r svn:file:///tmp/svnrepo/foo http://www.cpan.org/authors/id/R/RG/RGARCIA/perl-5.10.0.tar.gz
-    $ shipwright import -r svn:file:///tmp/svnrepo/foo http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz --name mod_perl --no-follow
+    $ shipwright import http://www.apache.org/dist/httpd/httpd-2.2.9.tar.gz --name apache
+    $ shipwright import http://www.cpan.org/authors/id/R/RG/RGARCIA/perl-5.10.0.tar.gz
+    $ shipwright import http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz --name mod_perl --no-follow
     ( use --no-follow is because run Makefile.PL will hung if we don't have
       apache installed )
-    $ shipwright import -r svn:file:///tmp/svnrepo/foo ftp://xmlsoft.org/libxml2/libxml2-2.6.32.tar.gz --name libxml
-    $ shipwright import -r svn:file:///tmp/svnrepo/foo cpan:XML::LibXML
+    $ shipwright import ftp://xmlsoft.org/libxml2/libxml2-2.6.32.tar.gz --name libxml
+    $ shipwright import cpan:XML::LibXML
 
 Run I<shipwright help import> to see more options.
 
@@ -131,12 +139,12 @@ For more information on build scripts, see L<Shipwright::Manual::CustomizeBuild>
 For dists with I<CPAN>, I<SVK>, I<SVN>, I<Git> and I<Shipwright> types,
 we can simply use the I<update> cmd to update:
 
-    $ shipwright update -r svn:file:///tmp/svnrepo/foo cpan-XML-LibXML
+    $ shipwright update cpan-XML-LibXML
     (yeah, that's right, cpan:XML::LibXML will be named cpan-XML-LibXML)
 
 we can also specify the version we want to update to with --version arg:
 
-    $ shipwright update -r svn:file:///tmp/svnrepo/foo cpan-XML-LibXML --version 1.60
+    $ shipwright update cpan-XML-LibXML --version 1.60
 
 For other types, Shipwright can't find the latest version, so we have to tell 
 Shipwright where it is by I<relocate> cmd.
@@ -145,8 +153,8 @@ e.g. apache 2.2.10 is released one day, with download link
 L<http://apache.mirror.phpchina.com/httpd/httpd-2.2.10.tar.gz>, we need to 
 set the source url first before update.
 
-    $ shipwright relocate -r svn:file:///tmp/svnrepo/foo apache http://www.apache.org/dist/httpd/httpd-2.2.10.tar.gz 
-    $ shipwright update -r svn:file:///tmp/svnrepo/foo apache
+    $ shipwright relocate apache http://www.apache.org/dist/httpd/httpd-2.2.10.tar.gz 
+    $ shipwright update apache
 
 =head2 tweak manually 
 
@@ -157,7 +165,7 @@ no extra dependence will be set.
 
 So we need to do it manually, e.g. use the following cmd to do so
 
-    $ shipwright update -r svn:file:///tmp/svnrepo/foo apache --add-deps libxml
+    $ shipwright update apache --add-deps libxml
 
 =head2 build
 
@@ -169,6 +177,8 @@ $ ./bin/shipwright-builder
 Run I<./bin/shipwright-builder --help> to see more options and
 I<./bin/shipwright-builder --advanced-help> to see even more options.
 
+For the layout of shipwright's source, see L<Shipwright>.
+
 =head2 fiddle the vessel
 
 we can use bin/shipwright-filter to fiddle the vessel, e.g. removing pods.

commit 363d4f6ea7057630ce69a7d9b76a206654e8c26e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Sep 11 15:12:58 2009 +0400

    * add magic script that keeps POD in sync

diff --git a/xbin/update_pod.pl b/xbin/update_pod.pl
new file mode 100644
index 0000000..a0235c0
--- /dev/null
+++ b/xbin/update_pod.pl
@@ -0,0 +1,230 @@
+use strict;
+use warnings;
+
+use Pod::Simple;
+use Pod::Select;
+use File::Find;
+
+update_env();
+update_backends();
+update_sources();
+
+sub update_backends {
+    my @list = backends();
+
+    {
+        my $file_name = 'lib/Shipwright/Backend.pm';
+        my $buf = '';
+        open my $out_fh, '>', \$buf;
+        my $updater = new ListUpdater;
+        $updater->{'my_list'} = \@list;
+        $updater->parseopts(-want_nonPODs => 1);
+        $updater->parseopts(-process_cut_cmd => 1);
+        $updater->parse_from_file($file_name, $out_fh);
+        close $out_fh;
+
+        open $out_fh, '>:raw', $file_name;
+        print $out_fh $buf;
+        close $out_fh;
+    }
+}
+
+sub update_sources {
+    my @list = sources();
+
+    {
+        my $file_name = 'lib/Shipwright/Source.pm';
+        my $buf = '';
+        open my $out_fh, '>', \$buf;
+        my $updater = new ListUpdater;
+        $updater->{'my_list'} = \@list;
+        $updater->parseopts(-want_nonPODs => 1);
+        $updater->parseopts(-process_cut_cmd => 1);
+        $updater->parse_from_file($file_name, $out_fh);
+        close $out_fh;
+
+        open $out_fh, '>:raw', $file_name;
+        print $out_fh $buf;
+        close $out_fh;
+    }
+}
+
+sub update_env {
+    my @files = files_with_pod();
+
+    my %tmp;
+
+    my $pod_selector = Pod::Select->new;
+    $pod_selector->select('ENVIRONMENT|ENVIRONMENT VARIABLES');
+    foreach my $file (@files) {
+        my $buf = '';
+        open my $out_fh, '>', \$buf;
+        $pod_selector->parse_from_file( $file, $out_fh );
+        close $out_fh;
+
+        unless ( $buf ) {
+            print "no env in $file, skipping\n";
+            next;
+        }
+        $tmp{$file} = { pod => $buf };
+    }
+
+    my $parser = new EnvFinder;
+    while ( my ($file, $meta) = each %tmp ) {
+        my $buf = '';
+        open my $in_fh, '<', \$meta->{'pod'};
+        open my $out_fh, '>', \$buf;
+        $parser->parse_from_filehandle( $in_fh, $out_fh );
+        close $out_fh;
+
+        $meta->{'env'} = {$parser->result};
+        unless ( keys %{ $meta->{'env'} } ) {
+            print STDERR "File $file has env section but we couldn't parse it\n";
+        }
+    }
+    {
+        my %dups;
+        while ( my ($file, $meta) = each %tmp ) {
+            push @{$dups{$_} ||= []}, $file foreach keys %{ $meta->{'env'} };
+        }
+        foreach my $var ( grep @{$dups{$_}}>1, keys %dups ) {
+            print STDERR "ENV variable '$var' described in several files: "
+                . join( ', ', @{ $dups{$var} } ) ."\n";
+        }
+    }
+    my %env = map %{ $_->{'env'} }, values %tmp;
+
+    {
+        my $manual_fn = 'lib/Shipwright/Manual/ENV.pod';
+        my $buf = '';
+        open my $out_fh, '>', \$buf;
+        my $updater = new EnvUpdater;
+        $updater->{'env'} = \%env;
+        $updater->parse_from_file($manual_fn, $out_fh);
+        close $out_fh;
+
+        open $out_fh, '>:raw', $manual_fn;
+        print $out_fh $buf;
+        close $out_fh;
+    }
+}
+
+sub files_with_pod {
+    my @res;
+    find( {
+        wanted => sub {
+            return unless /\.pm$/ || $File::Find::dir =~ m{/bin$};
+            my $path = $File::Find::name;
+            return if $path =~ /Manual/;
+            push @res, $path;
+        },
+    }, 'bin', 'lib' );
+    return @res;
+}
+
+sub backends {
+    my @res;
+    find( {
+        wanted => sub {
+            return unless s/\.pm$//;
+            return if /^Base$/;
+            push @res, $_;
+        },
+    }, 'lib/Shipwright/Backend' );
+    return @res;
+}
+sub sources {
+    my @res;
+    find( {
+        wanted => sub {
+            return unless s/\.pm$//;
+            return if /^Base$/;
+            push @res, $_;
+        },
+    }, 'lib/Shipwright/Source' );
+    return @res;
+}
+
+
+package EnvFinder;
+
+use base 'Pod::Parser';
+
+sub begin_input { $_[0]->{'env_parser'} = {} }
+sub result { return %{ $_[0]->{'env_parser'} } }
+
+sub command {
+    my ($self, $cmd, $text, $line, $pod) = @_;
+
+    if ( $cmd eq 'item' ) {
+        unless ( $text =~ /^\s*([A-Z_]+)\s*-/ ) {
+            print STDERR "Couldn't parse '$text' for env var\n";
+        }
+        $self->{'env_parser'}{$1} = $pod->raw_text;
+    }
+
+    return (shift)->SUPER::command(@_);
+}
+
+package EnvUpdater;
+use base 'Pod::Parser';
+
+sub command {
+    my ($self, $cmd, $text, $line, $pod) = @_;
+
+    if ( $cmd eq 'item' ) {
+        if ( $text =~ /^([A-Z_]+)\b/ && $self->{'env'}{$1} ) {
+            $self->{'inside_env_item'} = 1;
+            my $out_fh = $self->output_handle;
+            print $out_fh delete $self->{'env'}{$1};
+            return;
+        }
+    }
+    elsif ( $cmd eq 'back' && keys %{ $self->{'env'} } ) {
+        my $out_fh = $self->output_handle;
+        print $out_fh $_ foreach values %{ $self->{'env'} };
+    }
+    $self->{'inside_env_item'} = 0;
+    return (shift)->SUPER::command(@_);
+}
+
+sub verbatim { (shift)->SUPER::verbatim(@_) unless $_[0]->{'inside_env_item'} }
+sub textblock { (shift)->SUPER::textblock(@_) unless $_[0]->{'inside_env_item'} }
+
+package ListUpdater;
+use base 'Pod::Parser';
+
+sub preprocess_paragraph {
+    my ($self, $text, $line) = @_;
+
+    my $out_fh = $self->output_handle;
+    print $out_fh $text if $self->cutting;
+
+    return (shift)->SUPER::preprocess_paragraph(@_);
+}
+
+sub command {
+    my ($self, $cmd, $text, $line, $pod) = @_;
+
+    if ( $cmd eq 'head1' && $text =~ /^SUPPORTED (BACKEND|SOURCE)S\s*$/s ) {
+        $self->{'inside_item'} = 1;
+
+        my $type = $1;
+        my $res = $pod->raw_text;
+        my @list = map "L<$_|Shipwright::${type}::$_>", sort @{ $self->{'my_list'} };
+        my $last = pop @list;
+        $res .= "Currently, the supported \L$type\Es are "
+            . join( ', ', @list )
+            ." and $last.";
+
+        my $out_fh = $self->output_handle;
+        print $out_fh $res ."\n\n";
+    } else {
+        $self->{'inside_item'} = 0;
+    }
+    return (shift)->SUPER::command(@_);
+}
+
+sub verbatim { (shift)->SUPER::verbatim(@_) unless $_[0]->{'inside_item'} }
+sub textblock { (shift)->SUPER::textblock(@_) unless $_[0]->{'inside_item'} }
+

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list