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

use warnings;
use strict;

use lib 'lib';     # use own current version to produce

use OODoc;

my $verbose      = $ARGV[0] || 0;

##### Synchronize these constants with the mkdist script.
my $workdir = '/tmp/OODoc';

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

##### Other constants
my $distribution = 'OODoc';
my $name         = 'Object Oriented Documentation';

my $pod_format   = 'pod2';         # install Bundle::Text::MagicTemplate first
#my $pod_format  = 'pod';          # runs out-of-the-box
my $html_format  = 'html';

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

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

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

my $doc  = OODoc->new
 ( distribution => $distribution
 , 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 files\n" if $verbose;
$doc->processFiles(workdir => $workdir);

#
# 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
  , append  => <<TEXT);

=head1 REFERENCES

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

=head1 COPYRIGHTS

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

Copyright (c) 2003-2006 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 =>
      [
      ]
  );
