#! /usr/bin/perl eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' & eval 'exec perl -w -S $0 $argv:q' if 0; # ****************************************************************** # Author: Chad Elliott # Date: 7/12/2006 # $Id$ # ****************************************************************** # ****************************************************************** # Pragma Section # ****************************************************************** use strict; use FileHandle; use FindBin; use File::Spec; use File::Basename; my $basePath = $FindBin::Bin; if ($^O eq 'VMS') { $basePath = File::Spec->rel2abs(dirname($0)) if ($basePath eq ''); $basePath = VMS::Filespec::unixify($basePath); } $basePath = dirname($basePath); unshift(@INC, $basePath . '/modules'); require ProjectCreator; require TemplateParser; require ConfigParser; require StringProcessor; # ****************************************************************** # Data Section # ****************************************************************** my %keywords; my %arrow_op; my $doc_ext = '.txt'; my $version = '1.3'; # ****************************************************************** # Subroutine Section # ****************************************************************** sub setup_keywords { my $language = shift; ## Get the main MPC keywords my $keywords = ProjectCreator::getKeywords(); foreach my $key (keys %$keywords) { $keywords{$key} = 1; } ## Get the MPC valid components $keywords = ProjectCreator::getValidComponents($language); foreach my $key (keys %$keywords) { $keywords{lc($key)} = 1; } ## Get the pseudo template variables my $pjc = new ProjectCreator(); $keywords = $pjc->get_command_subs(); foreach my $key (keys %$keywords) { $keywords{$key} = 1; } ## Get the template function names $keywords = TemplateParser::getKeywords(); foreach my $key (keys %$keywords) { $keywords{$key} = 1; } ## Get the template parser arrow operator keys $keywords = TemplateParser::getArrowOp(); foreach my $key (keys %$keywords) { $arrow_op{$key} = 1; } } sub display_template { my($fh, $cp, $input, $tkeys) = @_; print $fh '', "\n", "\n", " $input\n", " \n", "\n", "\n", "

$input

\n", " \n", " \n", " \n", " \n", " \n", " \n"; foreach my $key (sort keys %$tkeys) { my $desc = $cp->get_value($key) || ' '; my $def; if (defined $$tkeys{$key}) { foreach my $ikey (sort keys %{$$tkeys{$key}}) { if (defined $def) { $def .= ' or '; } else { $def = ''; } $def .= StringProcessor::process_special(undef, $ikey); } } ## Convert < and > to html friendly codes $desc =~ s//>/g; print $fh " \n", " \n", " \n", " \n", " \n"; } print $fh "
Template VariableDefault ValueDescription
$key", (defined $def ? $def : ' '), "$desc
\n", "\n"; } sub usageAndExit { print "document_template.pl v$version\n", "Usage: ", basename($0), "