#!/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 '.';

use OODoc;

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

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

##### Other constants
my $module       = 'OODoc';
my $name         = 'Object Oriented Documentation';
my $version      = '0.04';         # Change this for each release!!!

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

print "*** Producing $module version $version\n" if $verbose;

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
 ( module     => $name
 , version    => $version
 , verbose    => $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 => $distribution);

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

=head1 REFERENCES

See the $module 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 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 =>
      [
      ]
  );
