#!/usr/bin/perl
# Create the documentation for the Mail::Box module.
# This script can be called as part of the mkdist procedure, but also
# on its own.

use warnings;
use strict;

use lib 'lib';                  # latest version of MailBox
use lib '../OODoc/lib';         # use my latest version of OODoc
use lib qw/. tests/;            # use my own current version
use lib '../UserIdentity/lib';  # latest version of User::Identity
use lib '../MimeTypes/lib';     # latest version of MIME::Types
use lib '../ORL/lib';           # latest version of Object::Realize::Later

use lib '/home/markov/shared/netzwert/MailBoxN/lib';
                                # latest version of Mail::Box::Netzwert

use Mail::Box::IMAP4::Head;
use OODoc;

my $verbose      = $ARGV[0] || 0;
my $workdir      = '/tmp/MailBox';

-d $workdir
or mkdir $workdir
or die "Cannot create $workdir: $!\n";

##### Other constants
my $distribution = 'Mail::Box';
my $name         = 'E-mail handling with MailBox';

my $pod_format   = 'pod2';
#my $pod_format  = 'pod';
my $html_format  = 'html';

my $web          = 'public_html';
my $website      = 'http://perl.overmeer.net/mailbox/';

my $html_root    = "/mailbox/html";  # usually empty, but not for me
my $css          = "$html_root/mailbox.css";

#
# The OODoc object is created.  It is used to collect all the manual
# information in.
#

my $doc  = OODoc->new
 ( distribution => $distribution
 , project      => $name
 , verbose      => $verbose
 );

my $version = $doc->version;
print "*** Producing $distribution version $version\n" if $verbose;

#
# Reading all the manual pages
# This could be called more than once to combine different sets of
# manual pages in different formats.
#

print "* Processing Mail::Box files\n" if $verbose;

$doc->processFiles
 ( workdir => $workdir
 , select  => qr[^ lib/ .*? \.(pod|pm) $ ]x
 );

print "* Processing User::Identity files\n" if $verbose;

$doc->processFiles
 ( workdir => undef
 , source  => '../UserIdentity'
 , select  => qr[^ lib/ .*? \.(pod|pm) $ ]x

 , distribution => 'User::Identity'
 );

print "* Processing MIME::Types files\n" if $verbose;

$doc->processFiles
 ( workdir => undef
 , source  => '../MimeTypes'
 , select  => qr[^ lib/ .*? \.(pod|pm) $ ]x

 , distribution => 'MIME::Types'
 );

print "* Processing Object::Realize::Later files\n" if $verbose;

$doc->processFiles
 ( workdir => undef
 , source  => '../ORL'
 , select  => qr[^ lib/ .*? \.(pod|pm) $ ]x

 , distribution => 'Object::Realize::Later'
 );

#
# Prepare the collected information
#
# Prepare the collected information
# Expanding the inheritance relations and such, to simplify the
# production of manual pages in their different formats.
#
# Prepare the collected information
# Expanding the inheritance relations and such, to simplify the
# production of manual pages in their different formats.
#

print "* Preparation phase\n" if $verbose;
$doc->prepare;

#
# Create POD
# Produce manual pages in the usual Perl style.
#

print "* Creating POD\n" if $verbose;

$doc->create
  ( $pod_format
  , workdir => $workdir
  , select  => sub {my $manual = shift; $manual->distribution eq $distribution}
  , append => <<TEXT);

=head1 REFERENCES

See the MailBox website at L<$website> for more details.

=head1 COPYRIGHTS

Distribution version $version.
Written by Mark Overmeer (mark\@overmeer.net).  See the ChangeLog for
other contributors.

Copyright (c) 2001-2003 by the author(s). All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

TEXT

#
# Create HTML
#

print "* Creating HTML\n" if $verbose;

$doc->create
  ( $html_format
  , workdir        => "$web$html_root"

  , format_options =>
      [ html_root      => $html_root
      , html_meta_data => qq[<link rel="STYLESHEET" href="$css">]
      ]

  , manual_format =>
      [
      ]
  );

print "* Ready\n" if $verbose;
