156 lines (117 with data), 3.9 kB
#!/usr/bin/perl -w
# COPYRIGHT NOTICE
#
# Silico - A Perl Molecular Toolkit
# Copyright (C) 2008 David K. Chalmers and Benjamin P. Roberts,
# Department of Medicinal Chemistry, Monash University
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#<
#! makedoc
#? Generate Silico documentation using a simple markup scheme to extract
# comments from Silico programs, libraries and data files.
#
#. See silico_doc.pm for a description of the simple Silico markup syntax
# for documentation.
#>
use strict;
package Silico;
#########################
# Variable declarations #
#########################
use vars qw($SUBHASH);
################
# Start script #
################
silico_setup();
print_title("makedoc");
require silico_doc;
get_arguments2();
my $version = `pwd`;
chomp $version;
$version =~ s/\/doc//;
$version =~ s/.*\///;
my $file_tagged .= "<STD>File documentation generated on ".`date`."";
my $sub_tagged .= "<STD>Subroutine documentation generated on ".`date`."";
$file_tagged .= read_doc('0intro');
$file_tagged .= read_doc('0subroutines');
my @dirs = qw(../bin ../local ../data ../lib);
foreach my $dir (@dirs) {
my @files = glob("$dir/*");
$file_tagged .= "<HEAD2>Directory: $dir";
# Print file information
foreach my $file (@files) {
next if $file eq '0intro';
next if $file eq '0subroutines';
next if $file eq 'README';
next if $file =~ /\.new$/;
next if $file =~ /\.old$/;
# Read file information
my $t = read_doc($file);
$file_tagged .= $t;
read_doc_subroutine($file);
}
}
# Subroutine index
$sub_tagged .= "<HEAD2>Subroutine Index";
my $i = 0;
foreach (sort keys %$SUBHASH) {
$sub_tagged .= "<LIST><LINK#$i>$_";
++$i;
}
# Subroutine descriptions
$sub_tagged .= "<HEAD2>Subroutine descriptions";
$i = 0;
foreach (sort keys %$SUBHASH) {
$sub_tagged .= "<HEAD3><ANCH$i>$_";
$sub_tagged .= $SUBHASH->{$_};
++$i;
}
writetext($file_tagged, 'doc', 'txt');
writetext($file_tagged, 'doc', 'html');
writetext($sub_tagged, 'subroutines', 'txt');
writetext($sub_tagged, 'subroutines', 'html');
sub writetext {
my $tagged = $_[0];
my $filebase = $_[1];
my $format = $_[2];
my $filename = "$filebase.$format";
print "Writing $filename\n";
my $form = format_doc_txt($tagged) if $format eq 'txt';
$form = format_doc_html($tagged) if $format eq 'html';
open (OUTFILE, ">$filename")
|| silico_msg('d', "Can not create or open file $filename for writing!");
print OUTFILE $form;
close OUTFILE;
}
sub silico_setup {
#<
#? Locates the Silico libraries and reads in the parent library, silico.pm
#; Sets: $Silico::home_dir, $Silico::lib_dir, $Silico::data_dir, $Silico::FS
#; Requires: nothing
#; Returns: nothing
#>
use vars qw($data_dir);
if ($ENV{SILICO_HOME}) {
# Look for Silico location by environment variable
$Silico::FS = "/";
$Silico::home_dir = $ENV{SILICO_HOME}.$Silico::FS;
$Silico::data_dir = $Silico::home_dir."data".$Silico::FS;
$Silico::lib_dir = $Silico::home_dir."lib".$Silico::FS;
push @INC, substr($Silico::lib_dir, 0, -1);
} else {
die "Error: The environment variable SILICO_HOME is not set\n";
}
require silico;
}